Process of in-order traversal, Data Structure & Algorithms

Assignment Help:

In-order Traversal

 This process when executed iteratively also needs a stack and a Boolean to prevent the implementation from traversing any portion of a tree twice. The general process of in-order traversal follows the following steps:  

1.  push a NULL onto the stack.

2.  Starting with the root, proceed down the left side of the tree. As long as there is another left node following the present node, push the pointer to the current node onto the stack and move to the left node which follows it.

3.  When there are no more left nodes following the present node, process the current node.

4.  Check to see if the last left node has a right node (it obviously doesn't have a left node).

5.  If there is a right node then there is subtree to the right. This should be processed in following steps 2 to 4.

6.  If there is no right node then pop the last node from the stack (back up one node). Process this node and as this node has a left subtree that has already been processed, move to the right of the node and start looking for a left and right subtree again.  

 


Related Discussions:- Process of in-order traversal

Inorder traversal, Inorder traversal: The left sub tree is visited, then t...

Inorder traversal: The left sub tree is visited, then the node and then right sub-tree. Algorithm for inorder traversal is following: traverse left sub-tree visit node

Abstract Data Types, A useful tool which is used for specifying the logical...

A useful tool which is used for specifying the logical properties of a data type is called the abstract data type or ADT. The term "abstract data type" refers to the fundamental ma

State phong shading, Phong Shading Phong shading too is based on interp...

Phong Shading Phong shading too is based on interpolation, but instead of interpolating the colour value, it is the normal vector, which is interpolated for each point and a co

What is algorithm, What is Algorithm A finite sequence of steps for a...

What is Algorithm A finite sequence of steps for accomplishing some computational task. An algorithm should Have steps which are simple and definite enough to be done

Complexity of an algorithm, What do you mean by complexity of an algorithm?...

What do you mean by complexity of an algorithm? The complexity of an algorithm M is the function f(n) which gives the running time and/or storage space need of the algorithm i

Insertion sort, Data array A has data series from 1,000,000 to 1 with step ...

Data array A has data series from 1,000,000 to 1 with step size 1, which is in perfect decreasing order. Data array B has data series from 1 to 1,000,000, which is in random order.

Algorithm, Ask question #MWhich of the following is not a characteristic of...

Ask question #MWhich of the following is not a characteristic of good algorithm? inimum 100 words accepted#

Demonstration of polynomial using linked list, Demonstration of Polynomial ...

Demonstration of Polynomial using Linked List # include # include Struct link { Char sign; intcoef; int expo; struct link *next; }; Typedefstruct link

Examination, Write an algorithm for binary search. What are its limitations...

Write an algorithm for binary search. What are its limitations? .

Link list, algorithm for multiplication of two sparse matrices using link l...

algorithm for multiplication of two sparse matrices using link list

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