Data Structures
12 questions
Q1
Build a BST by inserting: 25, 15, 35, 10, 20, 30, 40. What is the postorder traversal?
Q2
Build a BST by inserting: 40, 20, 60, 10, 30, 50, 70. What is the preorder traversal?
Q3
Build a BST by inserting these values in order: 50, 30, 70, 20, 40, 60. What is the inorder traversal?
Q4
What is the postorder traversal of a BST built by inserting: 30, 10, 50, 20, 40?
Q5
A queue starts empty. After ENQUEUE(5), ENQUEUE(3), DEQUEUE(), ENQUEUE(7), ENQUEUE(2), DEQUEUE(), what is at the front?
Q6
What is the internal path length of a BST built by inserting: 50, 30, 70, 20, 40?
Q7
A stack contains (bottom to top): 5, 8, 3. After PUSH(7) and then two POP operations, what value is on top of the stack?
Q8
A stack is initially empty. What is the output?
PUSH(1)
PUSH(2)
PUSH(3)
A = POP()
B = POP()
PUSH(A + B)
OUTPUT: POP()
Q9
A queue contains (front to back): A, B, C. After ENQUEUE(D), DEQUEUE(), ENQUEUE(E), DEQUEUE(), what is at the front?
Q10
A stack is initially empty. After these operations, what is the value of Z?
PUSH(4)
PUSH(9)
X = POP()
PUSH(X + 3)
PUSH(7)
Y = POP()
Z = POP()
Q11
Build a BST by inserting: 50, 25, 75, 10, 30. How many leaf nodes does the tree have?
Q12
In a min-heap, after inserting 5, 3, 8, 1, 4 (in that order), what value is at the root?