Binary Tree Traversals ?


Traversing is the process of passing through every node exactly once in a binary tree. Traversing is also  called as visiting. There are 3- ways of traversing techniques.

1. preorder

2. Inorder

3. postorder

Preorder : In pre order traversal a root node is followed by its left sub tree and right sub tree.

    1.    Go to root node

    2.    Traversal the left sub tree

3.    Traversal the right sub tree

binary tree

O/P: ABCDEFGH

Inorder : In order traversal a root node is in between its left sub tree and right sub tree.

    1.    Traverse the left sub tree.

    2.    Process the root node.

    3.    Traverse the right sub tree.
binary tree


O/P: CBAEFDDG

Post Order:  In post order the left sub tree is traversed first and the right sub tree is traversal and then node is traversed . In this traversal the node is after its left and right sub tree.

    1.    Traverse the left sub tree.

    2.    Traverse the right sub tree.

3.    Process the root node.
binary tree


O/P:CBFEDGA


Related

Minimum spanning tree (MST)

Minimum spanning tree (MST) Minimum spanning tree for a weighted graph  G is a spanning tree such that the sum of the weight is less than (or)equal to sum of weights of every other spanning ...

Representation of a Graph ?

Representation of a  graph is the way of storing data values in  memory location as graph data structure. There are two types  of graph representation techniques. 1. Adjacency ma...

What is Spanning Tree?

Spanning tree: A spanning tree for an undirected graph G is a graph consisting of all the nodes of ‘G’ together with enough edges from G such that 1.There is a path b/w each pair of nodes i...

Post a Comment

emo-but-icon
:noprob:
:smile:
:shy:
:trope:
:sneered:
:happy:
:escort:
:rapt:
:love:
:heart:
:angry:
:hate:
:sad:
:sigh:
:disappointed:
:cry:
:fear:
:surprise:
:unbelieve:
:shit:
:like:
:dislike:
:clap:
:cuff:
:fist:
:ok:
:file:
:link:
:place:
:contact:

item