Starting from:

$20

linked list Solution

Using the material in the textbook (NumberList) as a sample, design your own linked list class to hold a series of integers. The class should have the following member functions:

append, insert (at a specific position, return -1 if that position doesn't exist), delete (at a specific position, return -1 if that position doesn't exist), print, reverse (which rearranges the nodes in the list so that their order is reversed), and search (which returns the position of a specific value in the list. Assume the first node is position 0. If the items is not found, then return a -1 which will tell the calling function that that value does not exist)

High level validation

Numerical data input from the user should be validated before sending to the mutator function. While a non-integer is entered, display error and get data.

Low level validation

Mutator functions which are told to access a node that doesn't exist should return a -1 so that the calling function can handle the problem.

menu-driven program to demonstrate your linked list capabilities. Make sure that you have proper constructors and destructors (a destructor must delete every node). Make your input and output professional. Break your code down into functions so as to maintain modular design. No global variables.

Demo your program as follows:

append node

append node

append node

append node

append node

print list

insert at position

print list

delete at position

print list

reverse

print list

search list

---------------

int displayMenu()

{

cout << " n" << endl;

cout << "**********************************MENU*************************" << endl;

cout << "* 1) Append Node *" << endl;

cout << "* 2) Insert at Position *" << endl;

cout << "* 3) Delete at Position *" << endl;

cout << "* 4) Print List *" << endl;

cout << "* 5) Reverse List *" << endl;

cout << "* 6) Search List *" << endl;

cout << "* 7) End Program *n" << endl;

More products