hw3-2010 - operations. For example, we could compare x to y...

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

View Full Document Right Arrow Icon
Selection, Heaps, Hashing October 18, 2010 Homework 3 Due Date: Tuesday, 26 October 2010 by end of lecture Problem 3-1. 15pts In Hire-Assistant (CLRS Chapter 5), assuming that the candidates are presented in random order, what is the probability that you hire exactly one time ? What is the probability that you hire exactly n times ? Problem 3-2. 15pts In the deterministic linear time selection algorithm we were dividing the array into groups of size 5. If instead of 5, we divide into groups of size 3: Will the algorithm be still correct ? Does it run in linear time ? Repeat the above analysis for the case where we divide into groups of 7. Any advantages of using 5 as opposed to some other number ? In other words, was our choice of 5 arbitrary ? Problem 3-3. 15pts Give an O ( n log k )-time algorithm to merge k sorted lists into one sorted list, where n is the total number of elements in all the input lists. Problem 3-4. 15pts Suppose we have an arbitrary data type that supports constant-time comparisons and copies but no other
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: operations. For example, we could compare x to y and swap them if x < y in constant time. Can we implement a data structure over this data type such that INSERT and EXTRACT-MAX both run in o (log n ) time? If so, provide main ideas behind the implementation. If not, prove it is impossible. Problem 3-5. 20pts CLRS 11-1, page 282 (page 249 in 2nd edition). Problem 3-6. 20pts CLRS 11-2, page 283 (page 250 in 2nd edition). Problem 3-7. Extra credit : Direct approach to nding the second smallest element in an array is to rst nd the minimum, delete it, and then nd the minimum in the remaining set. This results in (2 n constant ) comparisons. Show that we can do this using only n + O (log n ) comparisons in the worst case. More precisely, show that n + log 2 n 2 comparisons are sucient. 1...
View Full Document

Ask a homework question - tutors are online