Project 2: Single and Double LinkLists
Start: Tuesday, 1/21; Due: Monday, 2/3, by the beginning of class
Overview
This assignment will give you some practice on implementing single and double linklists.
You should work on this project individually.
Part 1: Operations of a Single Linklist
In class, we worked on programs implementing a single linklist and a double linklist. For single linklist, our program consists of the following three classes.
node.py
: the class implementing a single node.-
singleLinkList.py
: the class implementing various operations for a single linklist, such asinsert
,delete
, andlength
. -
main.py
: the "control" class that is responsible for constructing the linklist and calling it's functions (in the process getting input from the user and displaying the output).
singleLinkList.py
to perform the below operations. You should be able to find the program we worked on in class (for single linklist) on Moodle and make modification on top of the program.
1) First, add a push
function to singleLinkList.py
that takes in a value from the user, and add it to th end of the list. For example, if your linklist looks like the following:
After calling the function push(3)
, your linklist should look like the following:
2) Next, add a reverse
function that reverses the single linklist. For example, if your linklist looks like the following:
After calling reverse()
, your linklist should look like the following:
3) Next, add a removeDuplicate
function to singleLinkList.py
that removes all of nodes containing duplicate data from the linklist. The resulting linklist should contain only nodes with distinct data. For example, if your linklist looks like the following:
After calling removeDuplicate
, your linklist should look like the following:
The order of the nodes is not important as long as your resulting list doesn't containt nodes with duplicate data.
Finally, in main.py
, do some testing of the three new functions you just added to singleLinkList.py
. Please note that when doing unit testings, you must test all exception cases as well as normal cases. Please provide all of the exception cases and at lease two normal cases when testing each function. Please document each case with comments. I will give you more details on what I'm expecting during lectures and labs.
Part 2: Operations of a Double Linklist
For this part of the project, you will complete the lab section of Chapter 2 in your textbook (Secton 2.18: Sorted Number List Implementation). You will complete theinsert
and remove
functions in sortedNumberList.py
. Please feel free to implement any helper functions to assist you. If your insert
or remove
function is too long, and you can isolate any part of a function based on task, you should be using helper functions.
Please read and follow the instruction for the lab (in Section 2.18) carefully. Once you had implemented the insert
and remove
functions in sortedNumberList.py
. You should be able to run and submit your code via the textbook webpage. You do not need to submit to Moodle for this task.
What you must do/hand in
For part 1 of this project, you must submit the following classes via via Moodle.
node.py
: the class implementing a single node.-
singleLinkList.py
: the class implementing various operations for a single linklist, such asinsert
,delete
, andlength
. -
main.py
: the "control" class that is responsible for constructing the linklist and calling it's functions (in the process getting input from the user and displaying the output).
I understand that you will most likely only modify singleLinkList.py
and main.py
, but I would like you to submit all three files just in case.
For part 2 of this project, you wiil complete the code in Section 2.18 of your textbook. Please read the instructions in Section 2.18 carefully and submit your code according to the instruction.
Grading Guide
We will be using this grading guide when grading your lab.
Submission
Submit node.py
, singleLinkList.py
, and main.py
via Moodle. Be sure to select 2025 s-mcs-178-001, which is your lecture section, then click on the MCS-178 Project 2 Part 1 Submission: Single Link List link.
Submit part 2 of this project via Section 2.18 of your textbook (be sure to read the follow the submission instruction). There is a link on Moodle called "Project 2 Part 2: Double Link Lists" which links to Section 2.18 of Zybook.