sand
BAN USER
Comments (3)
Reputation 30
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
2
of 2 vote
A basic file system can be shown as managmenet of data in Files & Folders. It should also manage the space available.
FIles and folder structure can be representd using Composite pattern as below:
class FileEntity
{
// members common to File & Folder
// create, copy, delete, move, getInfo, open, etc
};
class Folder : public FileEntity
{
// a folder can have multiple FileEntity (folders or files)
vector<FileEntity> m_VecFileEntity;
// members of Folder
};
class File : public FileEntity
{
// members of File
};
class Drive
{
// members of Drive
// getFreeSpace, getTotalSpace, createPartition, etc
};
class FileSystem
{
vector<FileEntity> m_VecFileEntity;
vector<Drive> m_vecDrives;
};
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
This could be done in O(log n) time.
Sample code:
-------------------
- sand February 09, 2012