Non-recursive algorithm to traverse a tree in preorder, Data Structure & Algorithms

Assignment Help:

Write the non-recursive algorithm to traverse a tree in preorder.   

The Non- Recursive algorithm for preorder traversal is as follows:

Initially  push NULL onto stack and then set PTR=Root. Repeat the steps until PTR= NULL.

1. Preorder down the left most path routed at PTR.

2. Processing every node N on the path and pushing every right child if any onto the stack.[The traversing stops when (PTR)=NULL]

3. Backtracking: pop and assign to PTR the top element on stack. If PTR not equal to NULL then return to step 1 or else exit.  

 


Related Discussions:- Non-recursive algorithm to traverse a tree in preorder

Infix notation to postfix notation, Which data structure is required to cha...

Which data structure is required to change infix notation to postfix notation?    Stack function is used to change infix notation to postfix notatio n

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

what is frequency count with examble? examble?

A sort which relatively passes by a list, A Sort which relatively passes by...

A Sort which relatively passes by a list to exchange the first element with any element less than it and then repeats with a new first element is called as      Quick sort.

Algorithm for stack using array, write an algorithm for stack using array p...

write an algorithm for stack using array performing the operations as insertion ,deletion , display,isempty,isfull.

Algorithms, 2. Write a note on i) devising ii) validating and...

2. Write a note on i) devising ii) validating and iii) testing of algorithms.

BST has two children, If a node in a BST has two children, then its inorder...

If a node in a BST has two children, then its inorder predecessor has No right child

Explain np-complete decision problem, a. Determine the result of inserting ...

a. Determine the result of inserting the keys 4,19, 17, 11, 3, 12, 8, 20, 22, 23, 13, 18, 14, 16, 1, 2, 24, 25, 26, 5 in order to an empty B-Tree of degree 3. Only draw the configu

Life science, Define neotaxonomy. Discuss how electron microscopy can help ...

Define neotaxonomy. Discuss how electron microscopy can help in solving a zoological problem faced by taxonomist.

Hash table, Programming for hash table?

Programming for hash table?

Multikey file organization, what are the applications of multikey file orga...

what are the applications of multikey file organization?

5/10/2013 2:49:34 AM

Thanks for suggesting me this answer, appreciate your knowledge.

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