Menu

(Solved) : Implementing Exercising Linked List C Design Write Class Implements Ordered List Type Usin Q44150564 . . .

IMPLEMENTING AND EXERCISING A LINKED LIST inC++

Design and write a class that implements an orderedlist type using a linked list, and a program that exercises andtests the class’s list implementation. The items in the List willbe integers, but it should be easy to change thistype.
The class should implement the following operations on orderedlists of its element type:

Initialize a List to be empty (the defaultconstructor).

Dispose of the dynamic part of a List structure (thedestructor).

Re-initialize an existing List to be empty.

Insert a value into a List, in the appropriateposition. If the value is already present, the List isunchanged.

Remove a value from a List. If the value is notpresent, the List is unchanged.

Is a List empty?

Return the length of a List.

Report whether or not a particular value is present ina List.

Return the value of the kth element of aList.

Write out the values in a List, in order, to an outputstream.

The exercising program should be menu-driven andinteractive. The program will read and respond to commandsthat the user enters to manipulate an ordered list.
INPUT
The program reads commands to manipulate its List. These commandsconsist of a letter sometimes followed by an integer. For example,the command “i 25” tells the program to insert the value25 into the List.
OUTPUT
The program writes instructions and a menu of commands to theterminal, it prompts for the user’s input, and it outputs lists andelements of lists.
ERRORSThe program may assume that the input the user provides iscorrect; except that it will report if a position is beyond the endof a list (See the example below). Otherwise, it need not detectany errors.
EXAMPLE
A run of the program might look something like this:
This program responds to commands the user enters to manipulate anordered list of integers, which is initially empty. In thefollowing commands, k is a position in the list, and v is aninteger. e — Re-initialize the list to be empty. i v — Insert thevalue v into the list. r v — Remove the value v from the list. m– Is the list empty? l — Report the length of the list. p v — Isthe value v present in the list? k k1 — Report the k1th value inthe list. w — Write out the list. h — See this menu. q — Quit.–> i 27 –> i 42 –> i 15 –> i 33 –> i 14 –>m The list is NOT empty. –> w List: < 14, 15, 27, 33, 42> –> r 33 –> w List: < 14, 15, 27, 42 > –> p22 The value 22 is NOT present in the list. –> p 42 The value42 is present in the list. –> k 3 The 3th element of the listis 27. –> k 9 The list does not contain 9 values. –> q Thisexample does not illustrate everything the program might do;
OTHER REQUIREMENTS
Use a typedef statement to specify the item type in theclass’s list, so that this type can be changed easily.
Represent the list in a linked list,
Maintain the List’s elements in order; this is part of theinvariant of the implementation.
Consider carefully whether functions associated with the classshould be member functions, friend functions, or nonmemberfunctions.
HINTSCommands will consist of a letter followed perhaps by aninteger. These can be easily read with the extractor operator”>>”.
Question: What other ordered list operations might a classlike this one reasonably provide?

This program responds to commands the user enters to manipulate an ordered list of integers, which is initially empty. In the

This program responds to commands the user enters to manipulate an ordered list of integers, which is initially empty. In the following commands, K is a position in the list, and v is an integer. e– Re-initialize the list to be empty. iv — Insert the value v into the list. rv — Remove the value v from the list. m — Is the list empty? 1 — Report the length of the list. pv — Is the value v present in the list? k k1 — Report the kith value in the list. w — Write out the list. h — See this menu. q –Quit. –> i 27 –> i 42 –> i 15 –> i 33 –> i 14 –> m The list is NOT empty. –> W List: < 14, 15, 27, 33, 42 > –> r 33 –> W List: < 14, 15, 27, 42 > –> p 22 The value 22 is NOT present in the list. –> p 42 The value 42 is present in the list. –> k 3 The 3th element of the list is 27. –> K9 The list does not contain 9 values. –> 9. Show transcribed image text This program responds to commands the user enters to manipulate an ordered list of integers, which is initially empty. In the following commands, K is a position in the list, and v is an integer. e– Re-initialize the list to be empty. iv — Insert the value v into the list. rv — Remove the value v from the list. m — Is the list empty? 1 — Report the length of the list. pv — Is the value v present in the list? k k1 — Report the kith value in the list. w — Write out the list. h — See this menu. q –Quit. –> i 27 –> i 42 –> i 15 –> i 33 –> i 14 –> m The list is NOT empty. –> W List: –> r 33 –> W List: –> p 22 The value 22 is NOT present in the list. –> p 42 The value 42 is present in the list. –> k 3 The 3th element of the list is 27. –> K9 The list does not contain 9 values. –> 9.

Expert Answer


Answer to IMPLEMENTING AND EXERCISING A LINKED LIST in C++ Design and write a class that implements an ordered list type using a l…

OR