Inorder traversal, Data Structure & Algorithms

Assignment Help:

Inorder traversal: The left sub tree is visited, then the node and then right sub-tree.

Algorithm for inorder traversal is following:

  1. traverse left sub-tree
  2. visit node
  3. traverse right sub-tree

2209_Inorder traversal.png

Figure: An expression tree: An inorder traversal

Inorder traversal can be best explained by an expression tree, where the operators are at parent node & operands are at leaf nodes.

Let us assume the above expression tree .The postorder , preorder, and inorder traversal are following:

preorder Traversal :  + * / 4 2 7 - 3 1

 postorder traversal :  4 2 / 7 * 3 1 - +

inorder traversal    :  - ((((4 / 2) * 7) + (3 - 1))

 

There is another tree traversal (certainly, not very common) is called level order, where all the nodes of the similar level are first travelled starting from the root .

271_Inorder traversal1.png

Figure: Tree Traversal: Level Order


Related Discussions:- Inorder traversal

Explain Hashing, What do you mean by hashing? Hashing gives the direct ...

What do you mean by hashing? Hashing gives the direct access of record from the file no matter where the record is in the file. This is possible with the help of a hashing func

Define game trees, Game trees An interesting application of trees is th...

Game trees An interesting application of trees is the playing of games such as tie-tac-toe, chess, nim, kalam, chess, go etc. We can picture the sequence of possible moves by m

Booth algorithm, what is boot algorithm and some example

what is boot algorithm and some example

How conquer technique can be applied to binary trees, How divide and conque...

How divide and conquer technique can be applied to binary trees?  As the binary tree definition itself separates a binary tree into two smaller structures of the similar type,

Compound interest, Write the algorithm for compound interest

Write the algorithm for compound interest

Sorting, explain quick sort algorithm

explain quick sort algorithm

Best case, for i=1 to n if a[i}>7 for j=2 to n a[j]=a{j}+j for n=2 to n a...

for i=1 to n if a[i}>7 for j=2 to n a[j]=a{j}+j for n=2 to n a[k]=a[j]+i else if a[1]>4 && a[1] for 2 to a[1] a[j]= a{j]+5 else for 2to n a[j]=a[j]+i ..

Linked list, write an algorithm for multiplication of two sparse matrices u...

write an algorithm for multiplication of two sparse matrices using Linked Lists

State flowchart that take temperature input using pseudocode, Write an algo...

Write an algorithm using pseudocode which takes temperatures input over a 100 day period (once per day) and output the number of days when the temperature was below 20C and the num

Merge sort, #question. merging 4 sorted files containing 50,10,25,15 record...

#question. merging 4 sorted files containing 50,10,25,15 records will take time?

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd