Non-recursive algorithm, Data Structure & Algorithms

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


The Non- Recursive algorithm for preorder traversal is written below: Initially in the begnining

push NULL onto stack and then set PTR=Root. Keep on repeating the following steps until PTR= NULL.

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

2. Processing each node N on the path and pushing each right child if there is onto the stack.[The traversing will stop when (PTR)=NULL]

3. Backtracking: pop and assign to PTR the top element on stack. If PTR is not equal to NULL then return to step 1 otherwise it exits.




Posted Date: 7/10/2012 4:12:37 AM | Location : United States

Related Discussions:- Non-recursive algorithm, Assignment Help, Ask Question on Non-recursive algorithm, Get Answer, Expert's Help, Non-recursive algorithm Discussions

Write discussion on Non-recursive algorithm
Your posts are moderated
Related Questions
Explain how two dimensional arrays are represented in memory. Representation of two-dimensional arrays in memory:- Let grades be a 2-D array as grades [3][4]. The array will

Ways to implement abstract data types A large part of the study of data structures and algorithms is learning about alternative ways to implement an ADT and evaluating alternat

one to many one to one many to many many to one

#question.explain different types of errors in data transmission.

Varieties of Arrays In some languages, size of an array should be established once and for all at program design time and can't change during execution. Such arrays are known a

This is a unit of which targeted on the emerging data structures. Red- Black trees, Splay trees, AA-trees & Treaps are introduced. The learner must explore the possibilities of app

write a pseudocode to input the top speed (in km''s/hours) of 5000 cars output the fastest speed and the slowest speed output the average (mean) speed of all the 5000 cars answers

write an algorithm to insert an element at the beginning of a circular linked list?