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

Circular linked list, In a circular linked list There is no beginning a...

In a circular linked list There is no beginning and no end.

Find strongly connected components - dfs, A striking application of DFS is ...

A striking application of DFS is determine a strongly connected component of a graph. Definition: For graph G = (V, E) , where V refer to the set of vertices and E refer to the

Tree traversals, There are three kinds of tree traversals, namely, Postorde...

There are three kinds of tree traversals, namely, Postorder , Preorder and Inorder. Preorder traversal: Each of nodes is visited before its children are visited; first the roo

Hash clash, Q. What do you understand by the term by hash clash? Explain in...

Q. What do you understand by the term by hash clash? Explain in detail any one method to resolve the hash collisions.

Sort wars - sorting algorithm, If quicksort is so quick, why bother with an...

If quicksort is so quick, why bother with anything else? If bubble sort is so bad, why even mention it? For that matter, why are there so many sorting algorithms? Your mission (sho

Multiple Queues in a single dimension array, Implement multiple queues in a...

Implement multiple queues in a single dimensional array. Write algorithms for various queue operations for them.

Use a random number generator to create 10 numbers, Use a random number gen...

Use a random number generator to create 10 numbers between 1 and 1000 and store them in 2 different arrays.  The first array should contain the numbers as they are generated.  The

Implement the physat algorithm, The first assignment in this course require...

The first assignment in this course required you to acquire data to enable you to implement the PHYSAT algorithm (Alvain et al. 2005, Alvain et al. 2008) in this second assignment

Ruby implementation of the symbol abstract data type, Ruby implementation o...

Ruby implementation of the Symbol ADT Ruby implementation of the Symbol ADT, as mentioned, hinges on making Symbol class instances immutable that corresponds to the relative la

Efficient algorithms.., implementation of fast fourier transforms for non p...

implementation of fast fourier transforms for non power of 2

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