Mcqs On Hashmap in Java
Mcqs On Hashmap in Java
System.out.println(root.left.value);
53.
○ A) 10
○ B) 5
○ C) 15
○ D) null
Answer: B) 5
54. Which data structure is not typically associated with tree traversal?
○ A) Queue
○ B) Stack
○ C) LinkedList
○ D) Array
Answer: C) LinkedList
55. Which of the following algorithms can be used to check if a binary tree is
symmetric?
○ A) Depth-first search
○ B) Breadth-first search
○ C) Both A and B
○ D) None of the above
Answer: C) Both A and B
56. What is the maximum height of a binary tree with n nodes?
○ A) n
○ B) n/2
○ C) log(n)
○ D) log(n) + 1
Answer: A) n
57. In a binary search tree, what does the term "successor" refer to?
○ A) The largest node in the left subtree.
○ B) The smallest node in the right subtree.
○ C) The parent node.
○ D) The last node visited in traversal.
Answer: B) The smallest node in the right subtree.
58. What is the minimum number of nodes in a full binary tree of height h?
○ A) 2^h - 1
○ B) 2^(h+1) - 1
○ C) 2^h
○ D) h + 1
Answer: A) 2^h - 1
59. Which of the following is a property of a red-black tree?
○ A) Every node is either red or black.
○ B) The root is always black.
○ C) No two red nodes can be adjacent.
○ D) All of the above.
Answer: D) All of the above.
60. What is the result of a level-order traversal of the tree containing nodes [4, 2, 6, 1,
3, 5, 7]?
○ A) [4, 2, 6, 1, 3, 5, 7]
○ B) [1, 2, 3, 4, 5, 6, 7]
○ C) [1, 4, 2, 3, 6, 5, 7]
○ D) [4, 1, 2, 3, 6, 5, 7]
Answer: A) [4, 2, 6, 1, 3, 5, 7]