write the non-recursive algorithm to traverse a


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.  

 

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: write the non-recursive algorithm to traverse a
Reference No:- TGS0282454

Expected delivery within 24 Hours