Q. In which traversal method are nodes visited in ascending order for a binary search tree?
-
A.
Pre-order
-
B.
In-order
-
C.
Post-order
-
D.
Level-order
Solution
In In-order traversal of a binary search tree, nodes are visited in ascending order.
Correct Answer:
B
— In-order
Learn More →
Q. In which traversal method are nodes visited level by level?
-
A.
In-order
-
B.
Post-order
-
C.
Pre-order
-
D.
Level-order
Solution
Level-order traversal visits nodes level by level, starting from the root.
Correct Answer:
D
— Level-order
Learn More →
Q. What is the primary application of level-order traversal in binary trees?
-
A.
Finding the height of the tree
-
B.
Finding the maximum element
-
C.
Printing nodes level by level
-
D.
Sorting the elements
Solution
The primary application of level-order traversal is to print nodes level by level.
Correct Answer:
C
— Printing nodes level by level
Learn More →
Q. What is the result of an in-order traversal of a binary search tree?
-
A.
Nodes in random order
-
B.
Nodes in descending order
-
C.
Nodes in ascending order
-
D.
Nodes in level order
Solution
An in-order traversal of a binary search tree results in the nodes being visited in ascending order.
Correct Answer:
C
— Nodes in ascending order
Learn More →
Q. What is the space complexity of a recursive binary tree traversal?
-
A.
O(1)
-
B.
O(n)
-
C.
O(log n)
-
D.
O(n^2)
Solution
The space complexity of a recursive binary tree traversal is O(n) due to the call stack.
Correct Answer:
B
— O(n)
Learn More →
Q. What is the worst-case time complexity for inserting an element in a binary search tree?
-
A.
O(log n)
-
B.
O(n)
-
C.
O(n log n)
-
D.
O(1)
Solution
The worst-case time complexity for inserting an element in a binary search tree is O(n), which occurs when the tree is unbalanced.
Correct Answer:
B
— O(n)
Learn More →
Q. What is the worst-case time complexity for inserting an element in an unbalanced binary tree?
-
A.
O(log n)
-
B.
O(n)
-
C.
O(n log n)
-
D.
O(1)
Solution
The worst-case time complexity for inserting an element in an unbalanced binary tree is O(n), when the tree becomes a linear chain.
Correct Answer:
B
— O(n)
Learn More →
Q. Which data structure is used to implement depth-first search in a binary tree?
-
A.
Queue
-
B.
Stack
-
C.
Array
-
D.
Linked List
Solution
Depth-first search in a binary tree is typically implemented using a stack.
Correct Answer:
B
— Stack
Learn More →
Q. Which of the following is NOT a property of a binary search tree?
-
A.
Left child < parent
-
B.
Right child > parent
-
C.
All nodes are unique
-
D.
All nodes are at the same level
Solution
In a binary search tree, all nodes are not required to be at the same level; this is not a property of BSTs.
Correct Answer:
D
— All nodes are at the same level
Learn More →
Q. Which traversal method is best for creating a mirror image of a binary tree?
-
A.
In-order
-
B.
Post-order
-
C.
Pre-order
-
D.
Level-order
Solution
Post-order traversal is best for creating a mirror image of a binary tree, as it processes children before the parent.
Correct Answer:
C
— Pre-order
Learn More →
Q. Which traversal method visits the root node before its children?
-
A.
In-order
-
B.
Post-order
-
C.
Pre-order
-
D.
Level-order
Solution
In Pre-order traversal, the root node is visited before its children.
Correct Answer:
C
— Pre-order
Learn More →
Showing 1 to 11 of 11 (1 Pages)