# 6 - (is of the same size You can try ﬁtting a nut with a...

This preview shows page 1. Sign up to view the full content.

CS180 Winter 2011 Homework 6 The following homework was due Wednesday, February 23. 1. Consider two number a and b of length n , i.e. each of them is n bits long. A very simple solution for multiplying the two numbers takes O ( n 2 ) time. We want to improve the time taken. Give a better algorithm, and the time complexity. Hint: Lets say a = a 1 2 n 2 + a 2 and b = b 1 2 n 2 + b 2 . Now a · b = ( a 1 · b 1 )2 n +( a 1 · b 2 + b 1 · a 2 )2 n 2 + a 2 · b 2 . Now to evaluate a · b we need to solve four problems of smaller size. Can we evaluate a · b by solving fewer sub-problems? 2. Consider n nuts and n screws. Assume that for each screw there exists only one nut that ﬁts
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: (is of the same size). You can try ﬁtting a nut with a screw. After one such trial either the nut turns out to be bigger than the screw, or they ﬁt nicely or the nut turns out to be smaller than the screw. Give an algorithm to pair the nuts with the corresponding matching (of the same size) screws making as few ﬁtting trials (asymptotically) as possible. 3. Problem 5 Pg 248 from book. 1...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online