in reply to Re: Unrolling recursion
in thread Unrolling recursion
From a /msg request for dragonchild, here's pseudocode to do a directory traversal without recursion.
As opposed to a recursive solution:# Traverse the filesystem push to stack / while currentdirectory = pop stack open the currentdirectory foreach pathname in this directory if it's also a directory, push it (full path) on the stack close the current directory
call traverse(/) function traverse (currentdirectory) open currentdirectory foreach pathname in this directory if it's also a directory, traverse(pathname) close currentdirectory
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Re: Unrolling recursion
by broquaint (Abbot) on Mar 14, 2002 at 15:47 UTC |
In Section
Meditations