Question
It's a C++ question!!! Chapter 18 introduces you to linked lists . In this homework assignment you will use the algorithms presented in this chapter
It's a C++ question!!!
Chapter 18 introduces you to linked lists. In this homework assignment you will use the algorithms presented in this chapter to implement a list of names that should be kept in alphabetical order.
Section 18.2 defines the Linked List Operations based on a list of numbers. You will change this code to work with a list of names. You can keep single names only (without space).
struct ListNode
{
string name;
struct ListNode *next;
};
Rename class NumberList to something more appropriate like StringList or NamesList. You will also need to change the methods to work with strings instead of numbers. You will only need two of the list operations: insertNode and displayList. Change them to work with the new type. Keep the constructor and destructor. Note that the destructor needs to delete one node at a time as shown in Destroying the List section.
Your main program should instantiate an object of the NamesList and ask the user to enter a list of names, which you will insert in alphabetical order by calling the insertNode method. When the user is done entering the names, call the displayList method to display the names, which should be in alphabetical order.
Turn in one .cpp file with the class implementation and the main function.
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