Why record the queue size at each level?

Practice this question from Binary Tree Level Order Traversal - BFS queue Pattern Practice Quiz, with options and an explanation.

Question

Why record the queue size at each level?

Option A — Correct answer

To separate the current level from the next level

Option B

To sort values

Option C

To detect BST violations

Option D

To remove duplicate nodes

Explanation

It separates the current level from children added for the next level.

Binary Tree Level Order Traversal - BFS queue Pattern Practice Quiz

All questions · Previous question · Next question

Open on QuizMaker