Explain the data structures and algorithms that you would use to design an in-memory file system. Illustrate with an example in the code logic where possible.
Asked In: Amazon
A file system, in its most simplistic version, consists of Files and Directories. Each Directory contains a set of Files and Directories. Since Files and Directories share so many characteristics, we’ve implemented them such that they inherit from the same class, Entry.
Implemented Main logic in Java
Alternatively, we could have implemented Directory such that it contains separate lists for files and subdirectories. This makes the nurnberOfFiles () method a bit cleaner, since it doesn’t need to use the instanceof operator, but it does prohibit us from cleanly sorting files and directories by dates or names.
For data block allocation, we can use bitmask vector and linear search (see “Practical File System Design”) or B+ trees (see Reference or Wikipedia).
This article is contributed by Mr. Somesh Awasthi. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Unified Modeling Language (UML) | Class Diagrams
- Design a movie ticket booking system like Bookmyshow
- Design an online hotel booking system like OYO Rooms
- Lazy Loading Design Pattern
- Design the Data Structures(classes and objects)for a generic deck of cards
- Chain of Responsibility Design Pattern
- Facade Design Pattern | Introduction
- How to design a parking lot using object-oriented principles?
- How to prevent Singleton Pattern from Reflection, Serialization and Cloning?
- Java Singleton Design Pattern Practices with Examples
- Adapter Pattern
- Decorator Pattern | Set 1 (Background)
- Singleton Design Pattern | Implementation
- Design Patterns | Set 2 (Factory Method)
- Design Patterns | Set 1 (Introduction)