In-order traversal, Data Structure & Algorithms

Write steps for algorithm for In-order Traversal

This process when implemented iteratively also needs a stack and a Boolean to prevent the execution from traversing any portion or area of a tree twice. The common process of in-order traversal follows the following steps:

1.   push a NULL onto the given stack.

2.   starting with the root, proceed down the left side of the   tree. As long as  there is one more left node  following     the current  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 further left nodes following the current node, process the current node.

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

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

6.   if there is no right node in it 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.

 

 

 

Posted Date: 7/9/2012 10:10:15 PM | Location : United States







Related Discussions:- In-order traversal, Assignment Help, Ask Question on In-order traversal, Get Answer, Expert's Help, In-order traversal Discussions

Write discussion on In-order traversal
Your posts are moderated
Related Questions
Explain CAM software CAD/CAM software has been recognized as an essential tool in the designing and manufacturing of a product due to its ability to depict the designs and tool

Implement algorithm to solve 5-1 fifth order equation given.

What are the features of an expert system

Before programming a problem solution those employees a stack, we have to decide how to represent a stack by using the data structures which exist in our programming language. Stac

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

How to measure the algorithm's efficiency? It is logical to examine the algorithm's efficiency as a function of some parameter n showing the algorithm's input size. Instance

You are given two jugs, a 4-gallon one and a 3-gallon one. Neither has any measuring marker on it. There is a tap that can be used to fill the jugs with water. How can you get exac

Ans: I nsertion into the B-tree: 1.  First search is made for the place where the new record must be positioned. As soon as the keys are inserted, they are sorted into th

Write an assembly program to separate the number of positive numbers and negative numbers from a given series of signed numbers.

Program segment for deletion of any element from the queue delete() { int delvalue = 0; if (front == NULL) printf("Queue Empty"); { delvalue = front->value;