Introduction to Computer Science
CompSci 101 : Fall 2013

Problem Solving

Files on a computer are organized hierarchically in folders. Because folders can contain files or other folders, which can contain more files and more folders, the structure itself is recursive. This structure makes using recursive algorithms a natural technique for processing folders.

Consider the following problems with regards to the folders on your computer. Use this code to help you get started.

  1. List all files in a folder recursively.
    Visit all of the files in the given folder and its sub-folders and return a list of strings, the full path name of each file.
  2. List all files in a folder recursively, but only up to a certain depth.
    Instead of following contained folders indefinitely, one might want to only list files to a certain depth, that is the distance measured in nested sub-folders from the starting folder.
  3. List all files in a folder recursively whose size is greater than a given minimum size.
    Visit all of the files in the given folder and its sub-folders and return only those that are larger than a given size.
  4. Compute the maximum sized file in a folder recursively.
    Visit all of the files in the given folder and its sub-folders and return an int representing the largest size of all the files found.