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

Direct file organisation, It offers an effective way to organize data while...

It offers an effective way to organize data while there is a requirement to access individual records directly. To access a record directly (or random access) a relationship is

Algorithm to find maximum and minimum numbers, Give an algorithm to find bo...

Give an algorithm to find both the maximum and minimum of 380 distinct numbers that uses at most 568 comparisons.

Standard ways of traversing a graph, Q. Which are the two standard ways of ...

Q. Which are the two standard ways of traversing a graph?  Explain them with an example of each.  Ans:   T he two ways of traversing a graph are written below

Sorting on several keys, Thus far, we have been considering sorting depend ...

Thus far, we have been considering sorting depend on single keys. However, in real life applications, we may desire to sort the data on several keys. The simplest instance is that

What are the languages which support assertions, What are the languages whi...

What are the languages which support assertions Languages which support assertions often provide different levels of support. For instance, Java has an assert statement which t

Determine the area subdivision method, Area Subdivision Method In this ...

Area Subdivision Method In this method, the viewport is examined for clear decisions on the polygons situated in it, in regard to their overlap and visibility to the viewer. Fo

Representation of linked list in memory, Representation of Linked list in M...

Representation of Linked list in Memory:- Each node has an info part and a pointer to the next node also known as link. The number of pointers is two in case of doubly linked

Algorithm for finding a key by binary search technique, Q. Write down an al...

Q. Write down an algorithm for finding a key from a sorted list using the binary search technique or method.

Graph, adjacency multilist

adjacency multilist

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