CS1510 Data Structures
Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit
CS1510 Data Structures
Requirement
Using C++ Class and pointers, implement Single-Linked List of integers. You are not allowed to use STL. Consider the following for your linked list implementation:
Update the List class implementations in the lecture slides so that the List does not have any duplicate value.
Also make the necessary updates to the List class to maintain a sorted list (i.e. the Nodes are in increasing order of data values). In particular, replace all the insert methods, and replace them with insert(int x), which inserts x in the right position so that the List remains sorted.
Implement DeleteMid() to delete the middle element (when the list contains an odd number of elements) or middle two elements (when the list contains an even number of elements).
Using recursion, implement Ascend() and Descend() to display the entire list in ascending and descending orders, respectively.
Sample Input
3 // Total no of input sets
5 10 4 4 // Input set 1
1 5 3 5 9 -1 7 // Input set 2
5 4 3 2 -999 // Input set 3
Sample Output (for Input set 1)
Sorted List: 4 5 10
After Deleting Middle Element:
List: 4 10
Display List in Ascending Order:
4 10
Display List in Descending Order:
10 4
and so on for other sample input sets 2 and 3
2026-02-24