Data Structures Quiz 5
Suppose that we have implemented a priority queue by storing the items in a heap (using an array for the heap items). We are now executing a reheapification upward and the out-of-place node is at data[i] with priority given by data[i]. Which of the following boolean expressions is TRUE to indicate that the reheapification IS NOT YET DONE. -(i > 0) -(data[(i-1)/2] < data[i]) -(i > 0) && (data[(i-1)/2] < data[i]) -(i > 0) || (data[(i-1)/2] < data[i])
(i > 0) && (data[(i-1)/2 < data[i])
What is the minimum number of nodes in a full binary tree with depth 3? -3 -4 -8 -11 -15
15
Suppose T is a binary tree with 14 nodes. What is the minimum possible depth of T? -0 -3 -4 -5
3
Suppose that a B-tree is declared so that MAXIMUM (the maximum number of items in a node) is 84. What is the value of MINIMUM (the minimum number of items in a non-root node)? -42 -84 -21 -83
42
What is the minimum number of nodes in a complete binary tree with depth 3? -3 -4 -8 -11 -15
8
Which statement is true for a B-tree? -All entries of a node are greater than or equal to the entries in the node's children. -All leaves are at the exact same depth. -All nodes contain the exact same number of entres. -All non-leaf nodes have the exact same number of children.
All leaves are at the exact same depth
Select the one true statement. -Every binary tree is either complete or full. -Every complete binary tree is also a full binary tree. -Every full binary tree is also a complete binary tree. -No binary tree is both complete and full.
Every full binary tree is also a complete binary tree.
Give two different reasons to explain why the following binary tree is not a heap: 91 / \ 77 46 / \ \ 68 81 11
The binary tree is not a heap because 77 is less than 81, which is not allowed and 11 should be a left child of 46 instead of being a right child.
Consider the tree below. Which statement is correct? 14 / \ 2 11 / \ / \ 1 3 10 30 -The tree is neither complete nor full. -The tree is complete but not full. -The tree is full but not complete. -The tree is both full and complete.
The tree is neither complete nor full.
Suppose that a B-tree is declared so that MAXIMUM (the maximum number of items in a node) is 84. Write one clear sentence to describe why each node's data array is set up to hold up to 85 items (one more than MAXIMUM).
When a new entry is added, a node may temporarily have 85 items.
If a max heap is implemented using a partially filled array called data, and the array contains n elements (n > 0), where is the entry with the greatest value? -data[0] -data[n-1] -data[n] -data[2*n + 1] -data[2*n + 2]
data[0]
Consider the node of a complete binary tree whose value is stored in data[i] for an array implementation. If this node has a right child, where will the right child's value be stored? -data[i+1] -data[i+2] -data[2*i + 1] -data[2*i + 2]
data[2*i + 2]