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

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

View Full Document Right Arrow Icon
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.
Background image of page 1

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

View Full DocumentRight Arrow Icon
(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?
Background image of page 2
Background image of page 3

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

View Full DocumentRight Arrow Icon
(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.
Background image of page 4
Background image of page 5

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

View Full DocumentRight Arrow Icon
(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
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/04/2010 for the course COMPUTER S cs300 taught by Professor Unkown during the Spring '08 term at Korea Advanced Institute of Science and Technology.

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 Right Arrow Icon
Ask a homework question - tutors are online