this nonrecursive traversal uses a stack s1

traverse(pls)

/* Prints the info fields of all

records of the liststructure l.

*/

liststructurepointer *pls;

{

liststructurepointer ptr,null,setnull(),

next(),sublist();

stack s1;

null = setnull();

ptr = *pls;

setstack(&s1);

while ((ptr != null)||(!empty(&s1)))

if (ptr != null)

{

printrecord(pls,ptr);

if (complex(ptr))

{

push(next(ptr),&s1);

ptr = sublist(ptr);

}

else

ptr = next(ptr);

}

else

pop(&s1,&ptr);