Recursion and the base case

F-RECURSE-V4-3hard

Total every directory below

A directory-manifest tool reports path depth, reconstructs root-to-directory paths and totals bytes from supplied parent records.

What needs to change

Repair total so the manifest includes all bytes below each directory.

Reproduce

  1. Run main.go with go run with Sample tree and A wide folder, then compare every directory’s byte total.

Acceptance criteria

Your review marks · Saved in this browser. Test acceptance is tracked separately.

Notes

The main.go with go run reader, Tree and caller are supplied. Input is directory ID, parent ID (- for the root), and bytes of files directly in that directory. The supplied data is one connected acyclic tree with unique IDs, exactly one root, and every nonroot parent present. IDs are nonempty path components, not -, with no / or whitespace. At most 100 directories have own-byte counts from 0 to 100, so every subtree total is at most 10000. The reader does not validate these supplied-data bounds; no filesystem is read.

Sign in to open this exercise

The ticket brief is public. Sign in to access the exercise. Paid exercises require Pro.

Sign in