Chapter 17 Questions
Multiple Choice Questions
1. A heap whose root contains the item with the largest search key is called a ______.
a. minheap
b. maxheap
c. complete heap
d. binary heap
2. A heap whose root contains the item with the smallest search key is called a ______.
a. minheap
b. maxheap
c. complete heap
d. binary heap
3. A heap is a ______.
a. general tree
b. table
c. full binary tree
d. complete binary tree
4. A semiheap is a ______.
a. table
b. complete binary tree
c. general tree
d. full binary tree
5. In an array-based implementation of a heap, the number of array items that must be swapped to transform a
semiheap of n nodes into a heap is ______.
a. n
b. n + 1
c. log2 n
d. log2 (n + 1)
6. In an array-based implementation of a heap, the remove operation is ______.
a. O(1)
b. O(n)
c. O(n 2)
d. O(log n)
7. In an array-based implementation of a heap, the parent of the node in items[i] is always stored in ______.
a. items[i/2]
b. items[(i-1)/2]
c. items[i-2]
d. items[(i-2)/2]
8. In an array-based implementation of a heap, the add operation is ______.
a. O(1)
b. O(n)
c. O(n 2)
d. O(log n)