Exercise 2: Depth and Height of the File System Tree — Possible Solution ==================================================================== GIVEN ------------------------------ root -> {docs, src} docs -> {readme.txt} src -> {main.py, utils.py} COMPUTING DEPTH (DISTANCE FROM ROOT) FOR EVERY NODE ------------------------------ root: 0 steps from itself -> depth 0 docs: one step from root (root -> docs) -> depth 1 src: one step from root (root -> src) -> depth 1 readme.txt: one step from docs, which is depth 1 -> depth 2 main.py: one step from src, which is depth 1 -> depth 2 utils.py: one step from src, which is depth 1 -> depth 2 Full depth table: root = 0 docs = 1 src = 1 readme.txt = 2 main.py = 2 utils.py = 2 TREE HEIGHT ------------------------------ Height is the greatest depth reached by any node. The deepest nodes here are readme.txt, main.py, and utils.py, all at depth 2. Height = 2 WHY THIS WORKS AS AN ANSWER ------------------------------ Every node's depth is computed as exactly one more than its own parent's depth, applied consistently down every branch (docs and src both computed relative to root, then their own children computed relative to them in turn), and the height is correctly identified as the single greatest depth value found anywhere in the tree, per this chapter's own definitions.