{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# mid1-q3 - log n Grading Upto 6 points – Using binary...

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

COT 5405 Fall 2009 Midterm I Q3 Sol A decision tree for the problem can be as follows: X : A[i] X : A[j] X : A[k] X : A[n] = < > = < > > > < = i j k n NO NO Here, each internal node represents a key-value comparison. Every internal- node has three children, for = , <, and > . A NO-node represents X not occuring in A . The = path immediately leads to the solution and therefore stops. Let us call this a solution-node. Since all values are distinct, and the key can be any value, the solutions nodes are atleast n . Each solution-node has a corresponding internal-node. Also, each internal-node has only two edges that hold other internal nodes. Given height h , the maximum number of internal-nodes you can pack into the tree is 2 0 + 2 1 + 2 2 + ... + 2 h = 2 h +1 - 1. 1

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

View Full Document
Clearly 2 h +1 - 1 n + 1 which gives us h ( log 2 n + 2) - 1 A search, in the wrost case, should traverse the height of the decision tree. Therefore, search has a lower bound of Ω(
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: log n ). Grading Upto 6 points: – Using binary search algorithm as the argument for proving the lower bound. The solutions that talk about binary search fail to point out that the log n lower bound comes from having O ( n ) distinct elements. Using such binary search argument it is possible to show that search in an array with all elements having same value (for which we can come up with a O (1) algorithm, assuming we know that information before hand) has a lower bound of log n . – Using some form of reduction, in the right direction. From 8 to 14 points: – Using height of the decision tree for lower bound, but a mistake in the argu-ment. From 16 to 20 points: – Mostly precise proof about height of the decision tree. 2...
View Full Document

{[ snackBarMessage ]}

### Page1 / 2

mid1-q3 - log n Grading Upto 6 points – Using binary...

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

View Full Document
Ask a homework question - tutors are online