Answer: PROCEDURE INORDER(T)
[Given a binary tree whose root node address is given by the pointer variable T, this algorithm traverses the tree in inorder in an iterative manner].
1. [Initialize]
If T = NULL
then write (“Empty Tree”)
return
else
TOP <-- 0.
2. [Process each stack branch address]
Repeat step 3 while TOP > 0.
3. [Get stored address and branch left]
flag <-- 0
while T != NULL
while flag != 1
call push(S,TOP,T)
T <-- LPTR(T)
if T = NULL
flag <-- 1.
4. [Traverse the right side]
D <-- pop(S,TOP)
write DATA(D)
T <-- RPTR(D)
flag <-- 0
while T = NULL
D <-- POP(S,TOP)
write DATA(D)
if TOP = 0
return
else
T <-- RPTR(D).
5. [FINISH]
return.