lect10-long-int-multiply

lect10-long-int-multiply - Lecture Notes CMSC 251 Since n/...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Lecture Notes CMSC 251 Since n/ 5 and 3 n/ 4 are both less than n , we can apply the induction hypothesis, giving T ( n ) c n 5 + c 3 n 4 + n = cn 1 5 + 3 4 + n = cn 19 20 + n = n 19 c 20 + 1 . This last expression will be cn , provided that we select c such that c (19 c/ 20) + 1 . Solving for c we see that this is true provided that c 20 . Combining the constraints that c 1 , and c 20 , we see that by letting c = 20 , we are done. A natural question is why did we pick groups of 5? If you look at the proof above, you will see that it works for any value that is strictly greater than 4. (You might try it replacing the 5 with 3, 4, or 6 and see what happens.) Lecture 10: Long Integer Multiplication (Thursday, Feb 26, 1998) Read: Todays material on integer multiplication is not covered in CLR. Office hours: The TA, Kyongil, will have extra office hours on Monday before the midterm, from 1:00-2:00. Ill have office hours from 2:00-4:00 on Monday. Long Integer Multiplication: The following little algorithm shows a bit more about the surprising applica- tions of divide-and-conquer. The problem that we want to consider is how to perform arithmetic on long integers, and multiplication in particular. The reason for doing arithmetic on long numbers stems from cryptography. Most techniques for encryption are based on number-theoretic techniques. For example, the character string to be encrypted is converted into a sequence of numbers, and encryption keys are stored as long integers. Efficient encryption and decryption depends on being able to perform arithmetic on long numbers, typically containing hundreds of digits. Addition and subtraction on large numbers is relatively easy. If n is the number of digits, then these algorithms run in ( n ) time. (Go back and analyze your solution to the problem on Homework 1). But the standard algorithm for multiplication runs in ( n 2 ) time, which can be quite costly when lots of long multiplications are needed. This raises the question of whether there is a more efficient way to multiply two very large numbers. It would seem surprising if there were, since for centuries people have used the same algorithm that we all learn in grade school. In fact, we will see that it is possible. Divide-and-Conquer Algorithm: We know the basic grade-school algorithm for multiplication. We nor- mally think of this algorithm as applying on a digit-by-digit basis, but if we partition an n digit number into two super digits with roughly n/ 2 each into longer sequences, the same multiplication rule still applies....
View Full Document

This note was uploaded on 01/13/2012 for the course CMSC 351 taught by Professor Staff during the Fall '11 term at University of Louisville.

Page1 / 4

lect10-long-int-multiply - Lecture Notes CMSC 251 Since n/...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online