{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# final2008 - CS300 Algorithms 2008 Fall semester Final Exam...

This preview shows pages 1–7. Sign up to view the full content.

CS300 Algorithms 2008 Fall semester Final Exam. Name : ID No. : Dept. : question score 1 2 3 4 5 6 7 8 Total **Caution: Do not use Pseudo Code to describe algorithms.

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

View Full Document
(15pts) 1. We want to convert a list of n distinct keys into a MAX heap using the following algorithm. 1 procedure HEAPCONST ( n list , ) 2 begin 3 for 2 / n i = to 1 by -1 do 4 = k the key at node i 5 call ) , , ( FixHeap n k i 6 end Assuming that the list has already been sorted in the decreasing order, answer the following questions. (5pts) 1.1 In line 3, why does i start from 2 / n ? (5pts) 1.2 Show that the number of key comparisons is 1 - n regardless of whether n is even or odd. (5pts) 1.3 Why does the algorithm work more efficiently on such a list?

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

View Full Document
(15pts) 2. Consider the following problem: 2L : Given a set of n distinct keys(numbers), find the largest and nd 2 : largest keys. Answer the following questions: (5pts) 2.1 Describe how to solve the problem 2L with 2 log 2 - + n n key : comparisons. (5pts) 2.2 Based on an adversary argument, show that the number of direct losers : to the largest key is at least n 2 log . (5pts) 2.3 Show that the problem 2L requires at least 2 log 2 - + n n key : comparisons to be solved.

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

View Full Document
(20pts) 3. Let ) , ( E V G = be a directed graph. A relation R on V is defined as : follows: } for in to and to from paths exist there | ) , {( V u,v G u v v u v u R =
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 17

final2008 - CS300 Algorithms 2008 Fall semester Final Exam...

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

View Full Document
Ask a homework question - tutors are online