Steps of pre-order traversal, Data Structure & Algorithms

Pre-order Traversal

The method of doing a pre-order traversal iteratively then has the several steps(suppose that a stack is available to hold pointers to the appropriate nodes):

1. push NULL onto the stack

2. Begin at the root and begin execution

3. Write the information in the node

4. If the pointer to the right is not NULL push the pointer onto the stack  

 5. if the pointer to the left is not NULL move the pointer to the node on the left

6. if the pointer to the left is NULL pop the stack

7. repeat steps 3 to 7 until no nodes remain

 

Posted Date: 5/10/2013 2:13:42 AM | Location : United States







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

Write discussion on Steps of pre-order traversal
Your posts are moderated
Related Questions
ESO207: Programming Assignment 1 Due on 6 Sept, 2015. To be submitted online. Problem In this assignment you are required to implement k-way Merge Sort algorithm. In this version p

for(int i = 0; i for (int j = n - 1; j >= i ; j--){ System.out.println(i+ " " + j);

Q. Draw a B-tree of order 3 for the sequence of keys written below: 2, 4, 9, 8, 7, 6, 3, 1, 5, 10

Speed cameras read the time a vehicle passes a point (A) on road and then reads time it passes a second point (B) on the same road (points A and B are 100 metres apart). Speed of t

A B-tree of minimum degree t can maximum pointers in a node T pointers in a node.

Q. Can a Queue be represented by circular linked list with only one pointer pointing to the tail of the queue? Substantiate your answer using an example. A n s . Yes a

give me algorithm of simple interest

In this unit, we will describe a data structure called Graph. Actually, graph is a general tree along no parent-child relationship. In computer science, Graphs have several applica

Write an algorithm for getting solution to the Tower's of Hanoi problem. Explain the working of your algorithm (with 4 disks) with appropriate diagrams. Ans: void Hanoi(int

In this unit, the following four advanced data structures have been practically emphasized. These may be considered as alternative to a height balanced tree, i.e., AVL tree.