← Quiz: Tree Traversals: all 13 questions
Quiz: Tree Traversals · Question 6 of 13
In iterative preorder with a stack, why is the right child pushed before the left?
In iterative preorder with a stack, why is the right child pushed before the left?
- A.So the left child is popped (and visited) first
- B.To visit the right subtree first
- C.Because stacks cannot hold left children
- D.It makes no difference
Answer & explanation
Correct answer: So the left child is popped (and visited) first
A stack is last-in, first-out: pushing left last means it comes out first.
Can you get the rest right without peeking?
Take the timed Quiz: Tree Traversals quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →