Question: Here are the values in myList: 1 2 4 6 8 10 12 Inserting a value at position 0: values in the list are 99

Here are the values in myList: 1 2 4 6 8 10 12
Inserting a value at position 0: values in the list are 99 1 2 4 6 8 10 12 Inserting a value at position 99: values in the list are 99 1 2 4 6 8 10 12 100 Inserting a value at position 2: values in the list are 99 1 98 2 4 6 8 10 12 100 Removing node at position 0... values in the list are 1 98 2 4 6 8 10 12 100 Removing node at position 99... values in the list are 1 98 2 4 6 8 10 12 100 Removing node at position 4... values in the list are 1 98 2 4 8 10 12 100 Removing node at position 2... values in the list are 1 98 4 8 10 12 100 Before reversing the list 1 98 4 8 10 12 100 After reversing the list 100 12 10 8 4 98 1
Here is the code for the test driver:
#include
int main() { // Create an instance of IntList. IntList myList;
// Build a list. myList.appendNode(2); // Append 2 to the list myList.appendNode(6); // Append 6 to the list myList.appendNode(8); // Append 8 to the list myList.insertNode(1); // insert 1 in the list myList.insertNode(4); // insert 4 in the list myList.insertNode(12); //insert 12 in the list myList.insertNode(10); //insert 10 in the list
// Display the nodes. cout
//try insertion //insert a node at position 0 myList.insert(99, 0); cout
//insert a node at position 99 myList.insert(100, 99); cout
//insert a node at position 2 myList.insert(98, 2); cout
// Remove node at position 0. cout
// Try a position that is too big. cout
// Remove node at position 4. cout
// Remove node at position 2. cout
// reverse the list cout Design your own linked list class IntList to hold a series of integers (1) Provide a constructor for the class. The constructor initializes an empty list. IntListO (2) Provide a destructor for the class. The destructor destroys the list. ~IntListo Provide member functions as below (3) A member function that appends a node to the list. void appendNode(int value) (4) A member function that inserts a node in the list. void insertNode(int value) (5) A member function that displays all the values in the linked list. void print0 (6) A member function that rearranges the nodes in the list so that their order is reversed. void reverse) (7) A member function that inserts a new value at a specified position. A position of 0 means that the value will become the first item on the list, a position of 1 means that the value will become the second item on the list, and so on. A position equal to or greater than the length of the list means that the value is placed at the end of the list. void insert(int value, int position) (8) A member function that deletes a node at a specified position. A value of 0 for the position means that the first node in the list is deleted. The function does nothing if the specified position is greater than or equal to the length of the list. void removeByPos(int position,) Separate your class definition from implementation. Your class definition must be stored in a file called IntList.h". Your class implementation must be store hw4.cpp (posted on Canvas) to test your IntList class. The output is provided below d in a file called "IntList.cpp". Use the test driver
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
