DSAVisualiseData Structures & Algorithms Studio
Trees & Ordered Maps Hard

File System Size

Calculate recursive directory sizes and see how the source collects and filters files.

Trace input

Bounded JSON

Edit the lesson input, then build a deterministic source-linked trace.

This lesson validates its own input and operation limits.

Source scenarios

Complexity

BestO(D + F)
AverageO(D + F)
WorstO(D + F)
SpaceO(D + F)

Array state

Follow the active comparisons and writes.

Live snapshot

Current operation

Trace state
Ready to explore
Source behavior & common mistakes

Each directory stores its own files and child directories. Total size adds local files before recursively adding child totals. The iterator collects files depth first, pushes matching files onto a stack, then returns them in reverse collection order; its API documents that order as arbitrary.

  • A directory total includes files in every descendant, not only its direct files.
  • This implementation visits a directory's own files before its subdirectories.
  • The iterator first collects all files, then pushes matches onto a stack, so the concrete order is reversed.
  • File names are labels; duplicate names do not merge file identities.

Algorithm code

Java
FileSystem.java (pinned repository source)Step linked
The highlighted line follows the current step.

Ready to begin

Press Play to see what happens.

Detailed execution
Snapshot 1 / 1
Visited 0 · Comparisons 0 · Writes 0