Question 91
What is the minimum height of a Binary Tree with 15 nodes (root at height 0)?
Min height occurs in a complete/perfect binary tree: h = ceil(log2(N+1)) - 1 = ceil(log2(16)) - 1 = 4 - 1 = 3.
What is the minimum height of a Binary Tree with 15 nodes (root at height 0)?
Min height occurs in a complete/perfect binary tree: h = ceil(log2(N+1)) - 1 = ceil(log2(16)) - 1 = 4 - 1 = 3.
Consider a Hash Table of size 7 using double hashing h(k, i) = (h1(k) + i * h2(k)) % 7 where h1(k) = k % 7 and h2(k) = 1 + (k % 5). For k = 12, what is the initial probe index (i = 0)?
h1(12) = 12 % 7 = 5. For i = 0, h(12, 0) = (5 + 0) % 7 = 5.
Which of the following operations takes O(1) time in a Doubly Linked List when given direct reference to the node to be deleted?
With a direct pointer to node P, updating P.prev.next = P.next and P.next.prev = P.prev takes O(1) constant time.
In a strict Binary Tree where every non-leaf node has exactly 2 children, if the total number of nodes is 19, how many leaf nodes are there?
For a strict binary tree, N = 2*L - 1 => 19 = 2*L - 1 => 20 = 2*L => L = 10 leaf nodes.
What is the Postorder traversal of a tree with Root A, Left child B, and Right child C?
Postorder = Left, Right, Root => B, C, A.