Create a new class “SortedListClass” that is functionally similar to ListClass, except the insert( ) method is
changed so that it inserts new values into its list “by value” in ascending sorted order rather than specifying
the position with a parameter. The SortedListClass must also include an additional method “find( )”, that
searches the sorted list of data values and returns it’s position within the list of values, and SortedListClass
must have a fully implemented assignment operator=() method. Then modify the LabListMain.cpp main
program as described in the following instructions (step 7) below to test out the SortedListClass.
1. Create copies of the initial LabListP.h and LabListP.cpp files named as
SortedLabList.h and SortedLabList.cpp. Add these two new files to your project.
2. Modify the new SortedLabList header and implementation files so that they define and implement
the “SortedListClass” class (instead of the original “ListClass” class).
3. Change the declaration and implementation of the insert( ) method in SortedListClass to insert a
new item data value into the linked list “by value”, e.g.,
bool insert(ListItemType& newItem);
The actual position of the new node in the linked list is not specified with a parameter, but instead
the method must search through the existing list of items and insert the new node into its proper
position so that the sequence of data values in the nodes remain in ascending order.
4. Add a new method declaration and implementation to SortedListClass:
int find(ListItemType& dataItem) const;
find( x ) searches through the linked list to find dataItem x, and returns its position within the list of
items. Positions in the list are numbered beginning with position 1 (e.g., positions are from 1 .. k ).
If the dataItem is not found anywhere in the list, then find( x ) returns -1.
5. Complete the implementation of the assignment operator= ( ) method in SortedListClass.
(If you want, you may also complete this method implementation in the original ListClass, although
this is not required for this lab).
6. Note that your lab project will now have class implementations for both the original ListClass data
type and also the new SortedListClass data type.
7. Make the following changes to the ListLabMain.cpp main( ) program:
a. #include “SortedLabList.h” along with the original #include “LabListP.h”.
b. After creating the initial unsorted list of random data values in the listbyposition variable,
create a new variable of type SortedListClass.
c. Insert the same set of data values into your sorted list variable.
i. To do this, the main() program must iterate through the listbyposition data to retrieve
each of the data values one at a time, and then insert each data value into the sorted
ii. Once the full set of data values have been inserted into the sorted list, then output the
contents of the sorted list variable in a similar format as the listbyposition contents in
the original output listing (e.g., as shown in the example on page 1).
d. Produce another output table listing that shows for each item in the original listbyposition,
what position that item ended up being located in within the sorted list variable’s linked list.
e. Create another SortedListClass variable (using the default constructor for an empty list).
f. Use the assignment operator=( ) to make this second sorted list variable a copy of your first
sorted list variable.
g. Then remove the first two items from your first sorted list variable (e.g., list.remove(1) twice).
h. Then insert the data value (-10) into the second sorted list variable.