Breadth First Traversal

1.Introduction

  • What we interest is the whole ways to traversal binary tree

    • They very based on the order in which the nodes are accessed

  • Bread First: visit on the nodes of a same level before moving on to the next level

  • Depth First: reach into a tree as deep as possible get to a leaf

2.Breadth First Traversal

  • 1.Start from the root node and add it to a queue

  • 2.Dequeue and process the queue

    • Add it's left and right child to the tree

  • 3.Continue as long as the queue is not empty

Last updated