Steps of pre-order traversal, Data Structure & Algorithms

Assignment Help:

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

 


Related Discussions:- Steps of pre-order traversal

Siso-4bit register, explain working of siso-register to store 1011 and show...

explain working of siso-register to store 1011 and show timing diagram &table

How do collisions happen during hashing, How do collisions happen during ha...

How do collisions happen during hashing? Usually the key space is much larger than the address space, thus, many keys are mapped to the same address. Assume that two keys K1 an

Frequency count, what is frequency count with examble? examble?

what is frequency count with examble? examble?

Algorithm for similar binary tree, Q. The two Binary Trees are said to be s...

Q. The two Binary Trees are said to be similar if they are both empty or if they are both non- empty and left and right sub trees are similar. Write down an algorithm to determine

Algorithm to add element in the end of circular linked list, Q. Write down ...

Q. Write down an algorithm to add an element in the end of the circular linked list.        A n s . Algo rithm to Add the Element at the End of Circular Linked Lists

Multiple queue, #questionalgorithm for implementing multiple\e queues in a ...

#questionalgorithm for implementing multiple\e queues in a single dimensional array

Implementation of stack, In this unit, we have learned how the stacks are i...

In this unit, we have learned how the stacks are implemented using arrays and using liked list. Also, the advantages and disadvantages of using these two schemes were discussed. Fo

Adjacency matrix, Q. Give the adjacency matrix for the graph drawn below:  ...

Q. Give the adjacency matrix for the graph drawn below:                                                 Ans: Adjacency matrix for the graph given to us

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