Hash table used for key-value pair storage and retrieval
Solved Step by step with explanation- which of the following data structure will be required
Question
D. Stack
Answer
2. Enqueue the root node of the binary tree into the queue.
3. Start a loop until the queue is empty.
8. The traversal is complete when the queue becomes empty.
By using a queue, we ensure that the nodes are processed in a level-wise manner. Initially, the root node is enqueued, and then its children are enqueued one by one. As we dequeue nodes from the front of the queue, their children are enqueued at the back, ensuring that the next level is processed before moving on to subsequent levels.