Sale!

EECS 560 Lab 1 – Implementation of Singly Linked List

$30.00 $18.00

Category: You will Instantly receive a download link for .zip solution file upon Payment || To Order Original Work Click Custom Order?

Description

5/5 - (4 votes)

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:
1. IsEmpty() : Returns true if list is empty or head node is NULL.
2. Insert(x): Inserts an element at the end of linked list.
3. Delete(x): Deletes an element given if present else throws an error.
4. Smallest: Finds smallest element from the list.
5. Largest: Finds largest element from the list.
6. Average: Finds average of all the elements of the list.
7. Merge2Lists: Merges the new list with the old list. New merged list should be sorted in ascending
order.
8. 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:
1. Insert
2. Delete
3. Find Smallest number
4. Find Largest number
5. Average of numbers
EECS 560 Lab 1 – Implementation of Singly Linked List
Prof.: Dr.Shontz, GTA : Dhwani Pandya, Lei Wang
6. Merge2Lists
7. Print
8. Exit
>> 7
List: 12 25 27 8 2 57 43 90 4 66 1
——————————————————————————————————————-
Choose one operation from the options below:
1. Insert
2. Delete
3. Find Smallest number
4. Find Largest number
5. Average of numbers
6. Merge2Lists
7. Print
8. Exit
>> 1
Enter element to be inserted in list: 5
——————————————————————————————————–
Choose one operation from the options below:
1. Insert
2. Delete
3. Find Smallest number
4. Find Largest number
5. Average of numbers
6. Merge2Lists
7. Print
8. Exit
>> 7
List: 12 25 27 8 2 57 43 90 4 66 1 5
—————————————————————————————————————-
Choose one operation from the options below:
1. Insert
2. Delete
3. Find Smallest number
4. Find Largest number
5. Average of numbers
EECS 560 Lab 1 – Implementation of Singly Linked List
Prof.: Dr.Shontz, GTA : Dhwani Pandya, Lei Wang
6. Merge2Lists
7. Print
8. Exit
>> 1
Enter element to be inserted in list: 27
——————————————————————————————————–
Choose one operation from the options below:
1. Insert
2. Delete
3. Find Smallest number
4. Find Largest number
5. Average of numbers
6. Merge2Lists
7. Print
8. Exit
>> 7
List: 12 25 27 8 2 57 43 90 4 66 1 5 27
—————————————————————————————————————-
Choose one operation from the options below:
1. Insert
2. Delete
3. Find Smallest number
4. Find Largest number
5. Average of numbers
6. Merge2Lists
7. Print
8. Exit
>> 2
Enter the number to be deleted: 43
Delete was successful.
——————————————————————————————————————-
Choose one operation from the options below:
1. Insert
2. Delete
EECS 560 Lab 1 – Implementation of Singly Linked List
Prof.: Dr.Shontz, GTA : Dhwani Pandya, Lei Wang
3. Find Smallest number
4. Find Largest number
5. Average of numbers
6. Merge2Lists
7. Print
8. Exit
>> 7
List: 12 25 27 8 2 57 90 4 66 1 5 27
———————————————————————————————————————-
Choose one operation from the options below:
1. Insert
2. Delete
3. Find Smallest number
4. Find Largest number
5. Average of numbers
6. Merge2Lists
7. Print
8. Exit
>> 2
Enter the number to be deleted: 27
Delete was successful.
——————————————————————————————————————-
Choose one operation from the options below:
1. Insert
2. Delete
3. Find Smallest number
4. Find Largest number
5. Average of numbers
6. Merge2Lists
7. Print
8. Exit
>> 7
List: 12 25 8 2 57 90 4 66 1 5 27
———————————————————————————————————————-
EECS 560 Lab 1 – Implementation of Singly Linked List
Prof.: Dr.Shontz, GTA : Dhwani Pandya, Lei Wang
Choose one operation from the options below:
1. Insert
2. Delete
3. Find Smallest number
4. Find Largest number
5. Average of numbers
6. Merge2Lists
7. Print
8. 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:
1. Insert
2. Delete
3. Find Smallest number
4. Find Largest number
5. Average of numbers
6. Merge2Lists
7. Print
8. Exit
>> 3
Smallest number: 1
———————————————————————————————————————
Choose one operation from the options below:
1. Insert
2. Delete
3. Find Smallest number
4. Find Largest number
5. Average of numbers
6. Merge2Lists
7. Print
8. Exit
>> 4
Largest number: 90
EECS 560 Lab 1 – Implementation of Singly Linked List
Prof.: Dr.Shontz, GTA : Dhwani Pandya, Lei Wang
——————————————————————————————————————-
Choose one operation from the options below:
1. Insert
2. Delete
3. Find Smallest number
4. Find Largest number
5. Average of numbers
6. Merge2Lists
7. Print
8. Exit
>> 5
Average: 27
——————————————————————————————————————–
Choose one operation from the options below:
1. Insert
2. Delete
3. Find Smallest number
4. Find Largest number
5. Average of numbers
6. Merge2Lists
7. Print
8. Exit
>> 6
Enter new list to be merged
21 11 9 92 23 38 61
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:
1. Insert
2. Delete
3. Find Smallest number
4. Find Largest number
5. Average of numbers
6. Merge2Lists
7. Print
8. Exit
EECS 560 Lab 1 – Implementation of Singly Linked List
Prof.: Dr.Shontz, GTA : Dhwani Pandya, Lei Wang
>> 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:
1. Insert
2. Delete
3. Find Smallest number
4. Find Largest number
5. Average of numbers
6. Merge2Lists
7. Print
8. 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++.