Ceng213 Hw1
Ceng213 Hw1
Ceng213 Hw1
CENG 310
DATA STRUCTURES
Fall 2023
Programming Assignment 1 - Simple File System Implementation via
Linked Lists
Due: 6. November 2023 23:55
Submission: via CengClass
1 Objectives
In this programming assignment, you will first implement a doubly linked list with a dummy head
node. Then, using the linked list implementation, you will build a very simplified file system that supports
a single directory with multiple files. The details of the assignment are explained in the following sections.
Keywords: C++, Data Structures, Linked List, Doubly Linked List with Dummy Nodes, Files,
Directories.
The LinkedList class has its definition and implementation in LinkedList.h file and the Node class has
its definition and implementation in Node.h file.
1
2.2 LinkedList Class
2.2.1 LinkedList()
This is the default constructor. You should make necessary initialization(s) in this function. Don’t forget
that our list will be a doubly linked list with a dummy head node.
2.2.3 ∼LinkedList()
This is the destructor. You must deallocate all the memory that you had allocated before.
2
2.2.11 Node<T> *getNode(const T &data) const
You should search the linked list for the node that has the same data with the given data and return a
pointer to that node. You can use operator== to compare two T objects. If there exists multiple such
nodes in the linked list, return a pointer to the first occurrence. If there exists no such node in the linked
list, you should return NULL.
3
2.2.19 void removeNode(Node<T> *node)
You should remove the given node from the linked list. Don’t forget to make necessary pointer and size
modifications. If the given node is not in the linked list (i.e., the linked list does not contain the given
node), do nothing.
3.2 File
The File class represents a file in the directory. This class has a single private member variable called
LinkedList<Block> blocks which keeps the blocks of the file. A file is made up by the blocks that it
contains and the contents of the file can be obtained by sequential traversal of Blocks from the LinkedList
object blocks. Public methods of the File class are explained below.
4
File
Block 1
Directory head
std::string content
Node<Block> *prev
std::vector<File> files
size_t size
Block data
files[0]
Node<Block> *next
files[1] Block 2
Node<Block> *prev
std::string content
Block data
files[2] size_t size
Node<Block> *next
std::string content
… Node<Block> *next
size_t size
Node<Block> *prev
…
Block data Block n-1
size_t size
files[n-1]
5
3.2.7 void removeBlock(int index)
This function should remove the Block at the given index. If there exists no such index in the File, then
do nothing.
3.3 Directory
This class implements the simple directory structure. It has only a single private member variable called
files which is of the std::vector<File>. While implementing this class you can use std::vector class’s
member functions. Public methods of Directory class are explained below.
6
3.3.8 void removeBiggestFile()
This function should find the biggest file in the directory and remove it from the directory. In case of
multiple files with biggest size you should delete the file with the smallest index. If the directory is empty
do nothing.
4 Driver Programs
To enable you to test your LinkedList and Directory implementations, two driver programs, main_linkedlist.cpp
and main_directory.cpp are provided.
5 Regulations
1. You will use C++ Programming Language.
4. Those who do the operations (insert, remove, get) without utilizing the linked list will receive 0
grade.
5. Those who modify already implemented functions and those who insert other data variables or
public functions and those who change the prototype of given functions will receive 0 grade.
6. Options used for g++ are “-ansi -Wall -pedantic-errors -O0”. They are already included in the
provided Makefile.
8. Late Submission Policy: Each student receives 5 late days for the entire semester. You may
use late days on programming assignments, and each allows you to submit up to 24 hours late
without penalty. For example, if an assignment is due on Thursday at 11:30 pm, you could use 2
late days to submit on Saturday by 11:30 pm with no penalty. Once a student has used up all their
late days, each successive day that an assignment is late will result in a loss of 5% on that assignment.
No assignment may be submitted more than 3 days (72 hours) late without permission from the
course instructor. In other words, this means there is a practical upper limit of 3 late days usable
per assignment. If unusual circumstances truly beyond your control prevent you from submitting
an assignment, you should discuss this with the course staff as soon as possible. If you contact us
well in advance of the deadline, we may be able to show more flexibility in some cases.
9. Cheating: We have zero tolerance policy for cheating. In case of cheating, all parts involved
(source(s) and receiver(s)) get zero. People involved in cheating will be punished according to the
university regulations. Remember that students of this course are bounded to code of honor and its
violation is subject to severe punishment.
10. Newsgroup: You must follow ODTUClass for discussions and possible updates on daily basis.
7
6 Submission
• Submissions will be done via CengClass.
– You can submit your source files to CengClass and test your work with a subset of evaluation
inputs and outputs.
– Additional test cases will be used for evaluation of your final grade. So, your actual grades
may be different than the ones you get in CengClass.
– Only the last submission before the deadline will be graded.