$24
General Instructions:
In this lab you will implement Singly Linked List and some operations on the same in C++. This lab will help you brush up your basic C++ concepts. Your program is expected to produce output as shown in the document. It should take input from text file of integers(data.txt). Numbers from the text file should be read one by one and fed as input to nodes of Singly Linked List. You can’t store the input data in array/vector, it should be strictly stored in linked list. Your program should handle duplicate numbers while doing insert in the list and delete function should delete first occurrence of duplicate values.
Operations on Singly Linked List:
IsEmpty() : Returns true if list is empty or head node is NULL.
Insert(x): Inserts an element at the end of linked list.
Delete(x): Deletes an element given if present else throws an error.
Smallest: Finds smallest element from the list.
Largest: Finds largest element from the list.
Average: Finds average of all the elements of the list.
Merge2Lists: Merges the new list with the old list. New merged list should be sorted in ascending order.
Print(): Prints all elements of the list.
Expected Output:
data.txt elements: 12 25 27 8 2 57 43 90 4 66 1
Your program should produce the menu below and should work as per the sample given below.
However, we will test your code with other inputs than shown below.
----------------------------------------------------------------------------------------------------------------
Choose one operation from the options below:
Insert
Delete
Find Smallest number
Find Largest number
Average of numbers
Merge2Lists
Print
Exit
7
List: 12 25 27 8 2 57 43 90 4 66 1
-------------------------------------------------------------------------------------------------------------------
Choose one operation from the options below:
Insert
Delete
Find Smallest number
Find Largest number
Average of numbers
Merge2Lists
Print
Exit
1
Enter element to be inserted in list: 5
--------------------------------------------------------------------------------------------------------
Choose one operation from the options below:
Insert
Delete
Find Smallest number
Find Largest number
Average of numbers
Merge2Lists
Print
Exit
7
List: 12 25 27 8 2 57 43 90 4 66 1 5
----------------------------------------------------------------------------------------------------------------
Choose one operation from the options below:
Insert
Delete
Find Smallest number
Find Largest number
Average of numbers
Merge2Lists
Print
Exit
1
Enter element to be inserted in list: 27
--------------------------------------------------------------------------------------------------------
Choose one operation from the options below:
Insert
Delete
Find Smallest number
Find Largest number
Average of numbers
Merge2Lists
Print
Exit
7
List: 12 25 27 8 2 57 43 90 4 66 1 5 27
----------------------------------------------------------------------------------------------------------------
Choose one operation from the options below:
Insert
Delete
Find Smallest number
Find Largest number
Average of numbers
Merge2Lists
Print
Exit
2
Enter the number to be deleted: 43
Delete was successful.
-------------------------------------------------------------------------------------------------------------------
Choose one operation from the options below:
Insert
Delete
Find Smallest number
Find Largest number
Average of numbers
Merge2Lists
Print
Exit
7
List: 12 25 27 8 2 57 90 4 66 1 5 27
----------------------------------------------------------------------------------------------------------------------
Choose one operation from the options below:
Insert
Delete
Find Smallest number
Find Largest number
Average of numbers
Merge2Lists
Print
Exit
2
Enter the number to be deleted: 27
Delete was successful.
-------------------------------------------------------------------------------------------------------------------
Choose one operation from the options below:
Insert
Delete
Find Smallest number
Find Largest number
Average of numbers
Merge2Lists
Print
Exit
7
List: 12 25 8 2 57 90 4 66 1 5 27
----------------------------------------------------------------------------------------------------------------------
Choose one operation from the options below:
Insert
Delete
Find Smallest number
Find Largest number
Average of numbers
Merge2Lists
Print
Exit
2
Enter the number to be deleted: 77
Delete failed. Number was not found in the list.
------------------------------------------------------------------------------------------------------------------------
Choose one operation from the options below:
Insert
Delete
Find Smallest number
Find Largest number
Average of numbers
Merge2Lists
Print
Exit
3
Smallest number: 1
---------------------------------------------------------------------------------------------------------------------
Choose one operation from the options below:
Insert
Delete
Find Smallest number
Find Largest number
Average of numbers
Merge2Lists
Print
Exit
4
Largest number: 90
-------------------------------------------------------------------------------------------------------------------
Choose one operation from the options below:
Insert
Delete
Find Smallest number
Find Largest number
Average of numbers
Merge2Lists
Print
Exit
5
Average: 27
--------------------------------------------------------------------------------------------------------------------
Choose one operation from the options below:
Insert
Delete
Find Smallest number
Find Largest number
Average of numbers
Merge2Lists
Print
Exit
6
Enter new list to be merged
2111992233861
Merged List: 1 2 4 5 8 9 11 12 21 23 25 27 38 57 66 90 92
----------------------------------------------------------------------------------------------------------------------
Choose one operation from the options below:
Insert
Delete
Find Smallest number
Find Largest number
Average of numbers
Merge2Lists
Print
Exit
7
List: 1 2 4 5 8 9 11 12 21 23 25 27 38 57 66 90 92
--------------------------------------------------------------------------------------------------------------------------
Choose one operation from the options below:
Insert
Delete
Find Smallest number
Find Largest number
Average of numbers
Merge2Lists
Print
Exit
8
Done!
Submission instructions:
All files i.e. source files and Makefile (or Readme.txt) should be zipped in a folder.
Naming convention of the folder should be LastName_Lab1.zip (or .tar or .rar or .gz).
Email it to : dhwanipandya@ku.edu or lei.wang@ku.edu (your respective lab instructor) with subject line EECS 560 Lab1.
Your program should run on the Linux machines in Eaton 1005D using g++.