trees /usrmarkbookch ch figure coursealexjunk ch cop fallsprsumsyl syl syl junk billworkcoursecop fallgrades prog fallprog prog prog grades unix directory void filesystem::listallint depth const printnamedepth )/print the name of the object ifisdirectoryfor each file in this directory (for each childc listalldepth )figure pseudocode to list directory in hierarchical file system with the type declaration above indeedon some versions of unixif the normal command to print file is applied to directorythen the names of the files in the directory can be seen in the output (along with other non-ascii informationsuppose we would like to list the names of all of the files in the directory our output format will be that files that are depth di will have their names indented by di tabs our algorithm is given in figure as pseudocode the recursive function listall needs to be started with depth of to signify no indenting for the root this depth is an internal bookkeeping variableand is hardly parameter that calling routine should be expected to know about thusthe default value of is provided for depth the logic of the algorithm is simple to follow the name of the file object is printed out with the appropriate number of tabs if the entry is directorythen we process all children recursivelyone by one these children are one level deeperand thus need to be indented an extra space the output is in figure this traversal strategy is known as preorder traversal in preorder traversalwork at node is performed before (preits children are processed when this program is runit is clear that line is executed exactly once per nodesince each name is output once since line is executed at most once per nodeline must also be executed once per each directory in the unix file system also has one entry that points to itself and another entry that points to the parent of the directory thustechnicallythe unix file system is not treebut is treelike