Question: Linked Lists in C++ (Copy code below) ================= charList_main.cpp (Driver program) // This program demonstrates simple operations // on a linked list. #include #include charList.h
Linked Lists in C++
(Copy code below)
=================

charList_main.cpp (Driver program)
// This program demonstrates simple operations // on a linked list.
#include
int main() { // Define a NumberList object. CharList list;
// Append some values to the list. list.appendNode('t'); list.appendNode('s'); list.appendNode('n'); list.appendNode('m'); list.appendNode('j'); list.appendNode('f'); list.appendNode('c'); list.appendNode('a'); list.insertNode('y'); list.insertNode('0'); list.insertNode('9'); list.insertNode('o'); list.insertNode('p'); list.insertNode('@'); list.insertNode('Q'); list.deleteNode('t'); list.displayList(); return 0; }
charList.cpp (This is where code needs to be written. Two functions already defined)
// Implementation file for the NumberList class
// Your coding required here
//************************************************** // displayList shows the value * // stored in each node of the linked list * // pointed to by head. * // pre: an empty parameter list * // post: standard output of the linked list * //**************************************************
void CharList::displayList() const { ListNode *nodePtr; // To move through the list
// Position nodePtr at the head of the list. nodePtr = head; short count = 0;
// While nodePtr points to a node, traverse // the list. while (nodePtr) { // Display the value in this node. std::cout value "; ++count; // Move to the next node. nodePtr = nodePtr->next; if (count % 10 == 0) { std::cout
//************************************************** // Destructor * // This function deletes every node in the list. * // pre: n/a * // post: destroyed object * //**************************************************
CharList::~CharList() { ListNode *nodePtr; // To traverse the list ListNode *nextNode; // To point to the next node
// Position nodePtr at the head of the list. nodePtr = head;
// While nodePtr is not at the end of the list... while (nodePtr != nullptr) { // Save a pointer to the next node. nextNode = nodePtr->next;
// Delete the current node. delete nodePtr;
// Position nodePtr at the next node. nodePtr = nextNode; } }
For the assignment, we will design a descending order arranged linked list class. This linked list class should hold a series of char type values. The class should have member functions for appending, inserting, and deleting nodes. Also, it will need a destructor that destroys the list. For this assignment, you will need to provide these public member functions that perform the following tasks: a) appendNode appends a node containing the char value passed, to the end of the list. b) insertNode this function inserts a node with the char parameter's value copied to its char member element. This function must insert the values in descending order. Duplicates are okay. c) deleteNode this function searches for a node with char parameter's value as the element to find. The node, if found, is deleted from the list and from memory. If two or more nodes with the same value are found, only one is removed (your choice which one). The CharList class member-function definitions have been started for you with the displayList function and the destructor already given. Make sure to use the driver program as well. Find both the driver function and member-function definition files that have been provided in the folder under charList_main.cpp and charList.cpp, respectively. Please use the driver and make sure your program can execute the test cases successfully
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
