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
Q. How can we free the memory by using Boundary tag method in the context of Dynamic memory management?

Define the External Path Length The External Path Length E of an extended binary tree is explained as the sum of the lengths of the paths - taken over all external nodes- from

First - Fit Method: -    The free list is traversed sequentially to search the 1st free block whose size is larger than or equal to the amount requested. Once the block is found it

Binary: Each node has one, zero, or two children. This assertion creates many tree operations efficient and simple. Binary Search : A binary tree where each and every left

Construct a B+ tree for the following keys, starting with an empty tree.  Each node in the tree can hold a maximum of 2 entries (i.e., order d = 1). Start with an empty root nod

Q. What do you understand by the term Hashing?  How do the collisions occur during hashing?  Explain the different techniques or methods for resolving the collision.


As part of an experiment, a school measured heights (in metres) of all its 500 students. Write an algorithm, using a flowchart that inputs the heights of all 500 students and ou

Binary Search Tree usage: Write a program to compare the time taken for a search in a skewed tree, a balanced tree, and a random tree. Speci cally, your program should do the

Multidimensional array: Multidimensional arrays can be defined as "arrays of arrays". For example, a bidimensional array can be imagined as a bidimensional table made of elements,