In this assignment, you will implement additional member functions for the linke
ID: 3697866 • Letter: I
Question
In this assignment, you will implement additional member functions for the linked list data structure. Following are the member functions you need to implement. You can create additional member functions if you want to. Note: You can also put Node as an inner class in LinkedList class. You can’t use the STL library for this assignment.
LinkedList::LinkedList(const LinkedList& alinked_list)
Copy constructor.
int LinkedList::find(double x)
Searches the linked list and returns the number of times a node with data = x occurs in the linked list.
int LinkedList::search(double x)
Searches the linked list for a specified value (x). Returns the position of first node with data = x. If the value is not found in the linked list, return 0. The first node has position = 1.
void LinkedList::reverse()
Reverses the order of the nodes in the linked list.
void LinkedList::swap(int position1, int position2)
Swaps nodes at the two positions indicated by the two integers - position1 and position2. The first node has position = 1.
void LinkedList::InsertList(LinkedList aList)
Appends all the nodes in the argument LinkedList aList to the calling LinkedList object.
int LinkedList::size()
Returns the number of nodes in a liked list.
bool LinkedList::isSorted()
Returns a boolean true if the linked list is sorted (either descending or ascending) otherwise returns false.
void LinkedList::erase(int position1, int position2)
Deletes all nodes with location starting at position1 through position2. The first node has position = 1. Assume that position2> position1.
void LinkeList::sort()
Sorts the nodes in ascending order. You can implement either a bubble sort or selection sort.
Now write a main function that does the following. If you change the list, display the list after the operation.
Create a linked list (list1) that contains 10 nodes with data: 1, 2, 1, 4, 5, 2, 7, 8, 9, 10.
Create another linked list (list2) from list1 using copy constructor.
Reverse the order of nodes in list2.
Find and display the position of node with data = 4 in list1 and list2.
Deletes the nodes located at positions 5, 6, 7, 8, 9, and 10 in list2.
Test if list1 and list2 are sorted.
Find the number of nodes in list1 and list2.
Find and display the number of times a node with data = 2 occurs in list1 and list2.
Append all the nodes which are in list2 into list1.
Finally sort list1