Compute Entity Size and Validate a Hierarchical File System

Last updated: August 30, 2026

Quick Overview

This question asks the candidate to compute the total size of a specified entity within a hierarchical file system and to validate the structure of the file system itself.

Google
Software Engineering Fundamentals
Software Engineer
Google
August 30, 2026
Software Engineer
Onsite
Software Engineering Fundamentals
Medium

0

0

7 solved


This question asks the candidate to compute the total size of a specified entity within a hierarchical file system and to validate the structure of the file system itself.

This question is typically asked during the onsite interview round at Google to evaluate a candidate's understanding of data structures and algorithms, particularly in relation to file systems. The interviewer is looking for the candidate's ability to navigate complex data relationships and implement efficient algorithms to solve problems involving recursion and validation of hierarchical structures.

What the Interviewer Expects
  • Correctly compute the total size of the specified entity.
  • Implement a recursive approach to traverse the file system structure.
  • Validate the integrity of the file system, ensuring directories and files are correctly structured.
  • Handle edge cases, such as empty directories or circular references.
  • Provide clear and efficient code with appropriate complexity analysis.
Key Topics to Cover
Data Structures
Recursion
File Systems
Algorithm Complexity
Validation
How to Approach This
  1. Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
  2. Choose data structures based on access patterns, not familiarity.
  3. Prefer immutable data and message passing over shared mutable state for concurrency.
  4. Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
  • How would you handle circular references in the file system?
  • Can you explain the time and space complexity of your solution?
  • What other data structures could be used to represent a file system?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice System Design Problems
Sample Answer
Requirements

To solve this problem, we need to compute the total size of a given entity (either a file or a directory) in a hierarchical file system. Additionally, we need to validate that the file system adheres ...

High-Level Design

We can represent the file system using classes for File and Directory. Each File has a size attribute, while each Directory contains a list of files and subdirectories. The main functions will...


Submit Your Answer
Markdown supported

Related Questions