We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Using list is optional. The fact is that we need a First-In First-Out (FIFO) data structure. This is what a queue is normally used for. tomlankhorst figured out a way to emulate FIFO with a linked list.
The loop will first start with the root node that was added before it started. It will print the root node and then add the left node and the right node and do the same thing starting with the left node. Then the left node's children will be added.
Tree: Level Order Traversal
You are viewing a single comment's thread. Return to all comments →
Using
list
is optional. The fact is that we need a First-In First-Out (FIFO) data structure. This is what aqueue
is normally used for. tomlankhorst figured out a way to emulate FIFO with a linked list.The loop will first start with the
root
node that was added before it started. It will print the root node and then add the left node and the right node and do the same thing starting with the left node. Then the left node's children will be added.