[modified] Exam-2 Flashcards
For which of the following sorts does the decision tree model not apply?
a) insertion
b) LSD radix sort
c) merge-sort
d) quicksort
b) LSD radix sort
In the example of recycling the elements of a list in O(1) time, which situation holds?
a) both lists are circular
b) both lists are not circular
c) the list to be recycled is circular, the garbage list is not
d) the garbage list is circular, the list to be recycled is not
c) the list to be recycled is circular, the garbage list is not
Given a pointer to a node, the worst-case time to delete the node from a singly-linked list with n nodes in ascending order is:
Θ(n)
Suppose that only numbers in 1 … 100 appear as keys in a binary search tree. While searching for 50, which of the following sequences of keys could not be examined?
10, 40, 70, 30, 50
What does counting sort count?
the number of occurences for each possible key value
The subset sum problem takes n input values and attempts to find a combination of those values whose sum in m. The worst-case time to extract the solution from the dynamic programming table is:
O(n)
Which of the following will not be true regarding the decision tree for HEAP-SORT for sorting n input values?
a) every path from the root to a leaf will have O(n log n) decisions
b) the height of the tree is Ω(n log n)
c) there will be a path from the root to a leaf with Ω(n^2) decisions
d) there will be n! leaves
c) there will be a path from the root to a leaf with Ω(n^2) decisions.
Suppose a node x in an unbalanced binary search tree has two children, each storing one key. What is the first step to delete x?
find the successor of x
If POP is implemented as return stack[SP–], then PUSH of element X is implemented as:
stack[++SP] = X
Suppose a (singly) linked list is used to implement a queue. Which of the following is true?
a) like a circular queue, the maximum number of items is determined at initialization
b) the head points to the first element and the tail points to the last element
c) the tail points to the first element and the head points to the last element
d) one node is always wasted
b) the head points to the first element and the tail points to the last element
Which binary tree traversal corresponds to the following recursive code?
void traverse(noderef x) {
if (x==null) return;
traverse(x.left);
traverse(x.right);
// process x }
postorder
The purpose of the binary searches used when solving the longest (monotone) increasing subsequence (LIS) problem is:
to determine the longest possible increasing subsequence terminated by a particular input value
In a binary search tree, which element does not have a successor?
the maximum
The most accurate description of the time to perform a deletion in an unbalanced binary search tree with n keys and height h is:
Θ(h)
The time to fill in the dynamic programming matrix when computing the LCS for sequences of lengths m and n is:
O(n)
Given a pointer to a node, the worst-case time to delete the node from a doubly-linked list with n nodes in ascending order is:
Θ(1)
Suppose that only numbers 1 … 1000 appear as keys in a binary search tree. While searching for 500, which of the following sequences of keys could not be examing?
100, 1000, 200, 800, 300, 900, 500