This quiz is homework assignment #2. Any question you answered correctly in class were considered correct for the purposes of the assignment. Any question you did not answer or which you answered incorrectly was a short answer question for the homework assignment due in class on Wednesday.
In italics are instructions on how to answer each question for homework. The correct letter answer and an explanation of that answer is listed after each question.
Good luck!
Which of the following are listed in strictly increasing asymptotic order (i.e., the left function is asymptotically less than, or little-o, of the right function)?
Correct answer(s): (b)
f1 is little-o of f2 if and only if f1 is asymptotically upper bounded by f2 and f1 is not (i.e., they're not tight bounds for each other).
The left functions of (a), (c), (d), and (e) are not little-o of their right functions:
However, and . So, .
Which of the following is an asymptotically-tight (i.e. big-) bound for the recurrence: T(n)=T(n/2)+1?
Correct answer(s): (c)
So, for 2k = n or and assuming :
The following function is designed to make a computer user say that they see an albatross. It does this by asking them again and again until they go crazy and say that they do see one:
int Albatross(int n) If n=1 Then Return End If For i=1 to n Print ``Do you see the albatross now?'' End For Albatross(n/2)
Which of the following is an asymptotically-tight bound on the number of times the user would be asked about the albatross:
Correct answer(s): (b)
int Albatross(int n)
If n=1 Then O(1)
Return O(1)
End If O(1)
For i=1 to n n times throughloop
Print ``Do you see the albatross now?'' O(1)
End For O(1)
Albatross(n/2) T(n/2)
Note that since the function will stop at the Return if n=1.
Total time then is:
So, for 2k = n or and given :
Here, I appeal to the book which tells us that and we know that . So, every value of this sum is between 1/2 and 2 and it is regardless of the maximum value of i! (Our sum is actually a touch larger, but still constant.) Back to our regularly scheduled analysis:
Consider the following recurrence relation:
Suppose we expand this equation k recursive times as we did in class (assume that the recurrence stated above is correct for k=1). Then, in general we would have which of the following?
Correct answer(s): (b)
A certain tree has a depth of d, a maximum branching factor of b, and n nodes total. Which of the following must be true of the tree?
Correct answer(s): (a)
Which of the following is not equal to 3?
Correct answer(s): (e)
Which best describes the siblings of u?
Correct answer(s): (b)
The Queue ADT can be briefly described as FIFO (First In First Out) and the Stack ADT as LIFO (Last In First Out). Which of these best describes the Priority Queue ADT?
Correct answer(s): (b)
Always Best Out is a good description of a Priority Queue because the supported operation which removes nodes (deleteMin) always deletes the one with the best (lowest) priority.
Never Highest Out is not a good description because a Priority Queue of size one will return its highest priority element when its deleteMin is called. Another acceptable reason would be that some priority queues implement deleteMax rather than deleteMin without loss of generality (they just define ``best'' differently).
Finally, Priority Queues are like Stacks and Queues in that all three represent a collection of homogenous (same-typed) elements with two fundamental operations: one to put new elements in and one to remove existing elements. Moreover, the order of removal is well-defined (although what exactly the definition is is where these ADTs differ).