When we turn a computer off, it should remember the functions and the data we worked on. Otherwise we have to reenter everything when we turn it on again. Things that a computer is to remember for a long time are put into files. A file is a sequence of small pieces of data. For our purposes, a file resembles a list; we ignore why and how a computer stores a file in a permanent manner.
It is more important to us that, on most computer systems, the collection of files
is organized in
directories.
Roughly speaking, a directory contains some files and
some more directories. The latter are called subdirectories and may contain yet
more subdirectories and files, and so on. The entire collection is collectively
called a file system
or a directory tree.
Figure
contains a graphical sketch of a small directory
tree.
The tree's root directory
is TS. It contains one file, called
read!, and two subdirectories, called Text and Libs. The first
subdirectory, Text, contains only three files; the latter, Libs,
contains only two subdirectories, each of which contains at least one file. Each
box has one of two annotations. A directory is annotated with DIR, and a file is
annotated with a number, which signifies the file's size. Altogether TS
contains seven files and consists of five (sub)directories.
How many times does a file name read! occur in the directory
tree TS?
What is the total size of all the files in the tree? How deep is the tree (how many
levels does it contain)? Solution