Level order traversal OR Breadth First Search (BFS) | DSA with echocoding

Hey In this post we are going to know about Level order traversal know as Breadth First Search (BFS).

Breadth First Search (BFS) is used to access element in graph data structure and in this post we are using BFS with tree data structure. Because tree is also a kind of graph data structure.



In the above we can see a tree is constructed and first node is 1 which is root node in this example. So the value of this tree will be print(access) level by level. such as 
in level 00 there is node of data 1,
in level 01 there is node of data 2 and 3 ,
in level 02 there is node of data 4,5,6 and 7 and
Last level,level 03 which is not considering becuase there is no data it is Null. hence there are only 3 level. 

so the printed data is 1 2 3 4 5 6 7 level by level. this kind of traversal is called as level order traversal(BSF).

In programming this can be achieved by quequ data structure.

Comments