🔖 Background Information
The tree command is a utility that prints out the structure of files and folders starting from a given folder (robinharwood et al., 2023). For example, if I use the tree command from some folder on my disk, I might see the following:
$ tree path/to/folder/
path/to/folder/
├── some-file.txt
├── another-file.txt
├── subfolder
│ ├── my-code.cpp
│ └── my-code.h
└── last-file.txt
1 directories, 5 filesThe tree command treats the files and folders on your disk as a tree data structure. The name of the command makes sense!
A robust implementation of tree can be a bit complicated, but a GitHub user named Kevin Newton implements a simplified version of tree whenever they want to learn a new programming language (Newton, 2025). We will analyze their code in this lab.
🎯 Problem Statement
Read through the C++ or Java implementation of the tree function as written by Newton in his tree repository (Newton, 2025). Then, complete the following:
- Run his code on your computer and capture the output in a screenshot.
- Benchmark the execution of the code on a variety of different directory structures.
- Answer the Thought Provoking Questions.
✅ Acceptance Criteria
Read through the code in the tree repository, taking time to understand it fully. Then, complete the tasks outlined in the Problem Statement.
📋 Dev Notes
Benchmarking this code is quite difficult because you have to think about all of the different edge cases you might run into! Take time to think about a strategy for benchmarking the code rather than just diving in and doing it randomly.
🖥️ Example Output
N/A
📝 Thought Provoking Questions
- Report the results of your benchmarking trials. Be sure to visualize them in a way that your classmates can understand and interpret.
- How does the command work? Give a high-level description of how the command displays a tree in the console.
- Is the filesystem displayed by the
treecommand an example of a binary tree or a general tree? - What is the root node of the tree displayed by the
treecommand? - What are the leaf nodes of the tree displayed by the
treecommand? - What does it mean if two files are sibling nodes in the tree displayed by the
treecommand? - How might you generate a tree with the largest possible depth via the
treecommand? - In Unix-like operating systems, all the files on all the devices generally exist in a single hierarchy. In other words, there is one root directory called
/, and every file on the system is located under it somewhere. How does this relate to the idea of a tree data structure?
💼 Optional Extra Credit
N/A
🔗 Useful Links
N/A