midterm - COT5405 Analysis of Algorithms Midterm Solutions...

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: COT5405 Analysis of Algorithms Midterm Solutions March 12, 2008 1. Graded by Manna T ( n ) = T ( n ) + 1 = T ( n 1 2 1 ) + 1 = T ( n 1 2 2 ) + 2 = ... = T ( n 1 2 i ) + i . Assume n 1 2 i = c = some small constant such that T ( c ) = constant. Thus, T ( n ) = T ( n 1 2 i )+ i = T ( c )+ i = O ( i ). Now, since c 2 i = n , log n = 2 i log c , which implies i = log log n- log log c = O (log log n ). Therefore, T ( n ) = O (log log n ). Many of you gave answers like O (log n ) and ended up getting max 30-40% marks. The reason penalties are harsh is because this problem was one where you could get the answer by simply computing mechanically no special intuition needed to be shown. In such cases, in order to get full credit, you must get it perfect. Moral of the story: easy come, easy go . 2. Graded by Ravi We get an O (1) amortized cost for Extract-min by using leftover credit from Insert. An insert of an element is charged O ( log n ), the depth of the heap, but the actual cost is only the number of levels the element has to percolate up. The rest of the credit (equal to the depth of the node at which the element is positioned) is used for achieving a O (1) amortized cost for Extract-min. We define a potential function based on the depth of nodes in the heap. Depth is the number of edges need to traversed to reach a root from node. Let H i be the heap after i th operation. For a node x let d i ( x ) be the depth of x in H i ....
View Full Document

Page1 / 3

midterm - COT5405 Analysis of Algorithms Midterm Solutions...

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