Question
C++ void CLL::push(char data) { // You write - if the size is 0, add a first node in the linked list // by calling
C++
void CLL::push(char data) { // You write - if the size is 0, add a first node in the linked list
// by calling addFirst. Otherwise add a new node to the end of the linked list. Note that this
// linked list is circular, so you must make the last node's next pointer point to the first node.
}
void CLL::addFirst(char data) {
// you write - add the very first node to the linked list
}
void CLL::addAtFront(char data) {
// you write - if the size of the linked list is 0, add a first node by calling addFirst.
//Otherwise add a new node to the beginning of the list
//Since this linked list is circular, you must make the last node now point to this new node
//you just added to the front of the linked list
}
void CLL::removeNext(SNode *n) {
// Longest method - given node n, remove the next node in the linked list.
// you have 4 conditions:
//1: there's only one node in the list, in which case you delete that node and set the size to 0
//2: n's next node is a last node, in which case n becomes the new last node and n's next must point
// to the first node in the list (remember to decrease the size of the list)
//3: n's next node is the first node in the list (i.e., n is the last node in the list), in which case
// n's next becomes first's next, first is deleted, and first becomes n's next (again, remember
// to decrease the size)
//4: n is just some node in the middle of the list, in which case you should create a tmp node to point
// to n's next, then set n's next to n's next's next, and then delete the tmp node (again, decrease
// size).
}
void CLL::printList(){
// print out the data in each node in the linked list, starting at the first node.
}
You will also be modifying the file DuckDuckGoose.cpp to fill in the methods as defined below:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started