Implement rm -rf
Category: System Design
Design a function that replicates the behavior of the rm -rf command. You are provided with the following helper functions:
Delete(path) -> bool: Deletes the file or empty directory at the given path. Returnstrueon success,falseotherwise.IsDirectory(path) -> bool: Checks if the given path points to a directory. Returnstrueif it's a directory,falseotherwise.GetAllFiles(path) -> List: Returns a list of absolute paths of all files and directories within the given directory, recursively.
Your implementation must prevent Out-Of-Memory (OOM) errors, especially when dealing with very large directory structures.
AI interview prep
Core dilemma
Recursively deleting a potentially massive file tree without exhausting system memory or overwhelming the underlying delete operations.
3 tradeoffs and 3 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Implement rm -rf
Category: System Design
Design a function that replicates the behavior of the rm -rf command. You are provided with the following helper functions:
Delete(path) -> bool: Deletes the file or empty directory at the given path. Returnstrueon success,falseotherwise.IsDirectory(path) -> bool: Checks if the given path points to a directory. Returnstrueif it's a directory,falseotherwise.GetAllFiles(path) -> List: Returns a list of absolute paths of all files and directories within the given directory, recursively.
Your implementation must prevent Out-Of-Memory (OOM) errors, especially when dealing with very large directory structures.