All mock tests are FREE till 31 December — register to save your progress
Paper 2 CS · UNIT 07 · MOCK TEST

Mock 2 – Trees, Heaps & Hashing (Part 1)

Unit 7: Data Structures and Algorithms · 21 questions · about 25 minutes. Press End Mock any time to see your score and the correct answers.

All 11 topic-wise mocks in this unit
0 / 21 answered 00:00
Q1. Consider the following AVL tree: root = 60; left child of 60 = 50; right child of 60 = 70; right child of 70 = 80 (a balanced AVL tree of height 2).
What is the maximum number of nodes that can be inserted in the following AVL tree without changing its height?
Q2. The number of leaf nodes in a full 4-ary rooted tree of n nodes is
Q3. In open addressing, how are collisions typically resolved?
Q4. What is the height of the binary search tree obtained by inserting the numbers 40, 60, 50, 37, 52, 15, 8, 22 in the given order
Q5. How will the following min-heap appear on inserting the key 32?
Original min-heap (level order): 5, 10, 25, 30, 40, 50, 60, 70, 80, 90 (root 5; children of 5 are 10 and 25; children of 10 are 30 and 40; children of 25 are 50 and 60; children of 30 are 70 and 80; the only child of 40 is 90).
Q6. Which of the following trees are height balanced?
A. Binary Search Tree
B. AVL Tree
C. Red-Black Tree
D. B Tree
Choose the correct answer from the options given below:
Q7. Match List I (Hashing Collision Handling Method) with List II (Strategy)
List IList II
A. ChainingI. Check next slot
B. Linear ProbingII. Use the second hash function
C. Quadratic ProbingIII. Linked list at index
D. Double HashingIV. Skip slots using quadratic step
Q8. The correct sequence of constructing a Huffman tree is
A. Repeat until root formed
B. Create leaf nodes
C. Build priority queue
D. Combine lowest frequency nodes
Choose the correct answer from the options given below:
Q9. Consider the binary tree: A is the root with left child B and right child C; C has left child D and right child E; E has right child F; F has left child G and right child H. What will be the inorder traversal?
Q10. Arrange the following steps of the inorder traversal of a binary tree in the correct order.
A. Visit the left subtree
B. Visit the root node
C. Visit the right subtree
D. Start traversing by visiting the nodes in the rooted tree
E. Repeat the above three steps.
Choose the correct answer from the options given below:
Q11. Which of the following description(s) is/are true?
A. Red-Black Tree – guarantees worst case O(log n) time for search, insert & delete.
B. Trie – used for efficient prefix-based searches.
C. AVL Tree – self-balancing binary search tree with stricter balance criteria.
D. B-Tree – allows efficient search, insert, delete operations in disk-based systems.
Choose the correct answer from the options given below:
Q12. ______ is a self-balancing binary search tree where the path from the root to the farthest leaf is no more than twice as long as the path from the root to the nearest leaf.
Q13. Which of the following is TRUE?
Q14. Which data structure is typically used to implement a hash table?
Q15. Which collision resolution technique involves maintaining a linked list of collided keys?
Q16. 2-3-4 trees are B-trees of order 4. They are isometric to ______ trees.
Q17. Consider the following statements about the heap sort algorithm:
A. The MAX-HEAPIFY procedure, which runs in O(lg n) time, is the key to maintaining the max-heap property.
B. The BUILD-MAX-HEAP procedure, which runs in O(lg n) time, produces a max-heap from an unordered input array.
C. The MAX-HEAP-INSERT procedure, which runs in O(lg n) time, implements the insertion operation.
D. The HEAP-INCREASE-KEY procedure runs in O(n lg n) time to set the key of a new node to its correct value.
Choose the correct answer from the options given below:
Q18. A B-tree used as an index for a large database table has four levels including the root node. If a new key is inserted into this index, the maximum number of nodes that could be newly created in the process is
Q19. Given below are two statements: one is labelled as Assertion A and the other is labelled as Reason R.
Assertion A: AVL trees are more balanced than red-black trees, but they may cause more rotations during insertion and deletion.
Reason R: A red-black tree with n nodes has height greater than 2 log₂(n + 1), and an AVL tree with n nodes has height less than log_φ(√5 (n + 2)) − 2 (where φ is the golden ratio).
Q20. Consider a hash table of size 7 with starting index 0 and hash function (6x + 3) mod 4. Assuming the table is initially empty, which of the following is the content of the table when the sequence 1, 3, 8, 10, 5 is inserted using closed hashing (linear probing)? Here '_' denotes an empty location.
Q21. The height of a binary search tree built by inserting the words banana, peach, apple, pear, coconut, mango and papaya (in this order, alphabetical comparison) is: