CS 46101/56101 - Fall 2002
Design and Analysis of Algorithms
This (F)AQ will contain answers to questions asked during lecture for which there is not enough time to fully answer during the lecture as well as answers to question that are emailed to the instructor.
Question 1:
Why can't I find the information you said was on the web site?
ANSWER:
Your browser may have cached an older version of the page to which the information has been added. If you click the reload button of your browser you will obtain the most current version of the page in question.
Question 2:
Can you explain quadratic probing in more detail?
ANSWER:
Quadratic Probing is much like linear probing except that we search a chain of bukets based on a quatric function rather than a linear function. A collison occurs when we try to insert item (k,e) into bucket A[i], where i=h(k) (this is the hash function), and find it already occupied. Now we need to find a new bucket in such a way that we can follow a chain of collisions so we can retrieve it later. For quadratic probing we do this as follows: For j=0,1,2,..., where f(j) = j^2 (that's the quadratic part) we calculate new buckets using A[(i + f(j)) mod N]. for j=0 this gives us [(h(k) + 0) mod N] (which is the bucket we would have found without implementing any collision handling), if this bucket is not empty try j=1 this gives us [(h(k) + 20 mod N], if this bucket is also not empty try j=2, and so on until we find an empty bucket.
Question 3:
Can you review using stirling's approximation to explain the lower bound for comparision sorting?
ANSWER:
Theorem: Any decision tree that sorts n elements has height Omega(n lg n)
Using Theorem on properties of Binary trees:
What's the minimum # of leaves? ANSWER--> at least h + 1
What's the maximum # of leaves of a binary tree of height h? ANSWER--> at most 2^h
Clearly the minimum # of leaves is less than or equal to the maximum # of leaves.
There are n! permutations of n elements so there are at least n! leaves in a decision tree so:
Now taking logarithms we have : lg(n!) <= h
Stirling's approximation is:
n! = Sqrt(2 pi n) (n/e)^n (1 + 1/12n + epsilon(n))
This tells us:
Thus: