# Lab 1 Implementation of Singly Linked List Solution

\$28.20

Quantity

Offer ends in

## Description

Rate this product

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.

1. IsEmpty() : Returns true if list is empty or head node is NULL.

1. Insert(x): Inserts an element at the end of linked list.

1. Delete(x): Deletes an element given if present else throws an error.

1. Smallest: Finds smallest element from the list.

1. Largest: Finds largest element from the list.

1. Average: Finds average of all the elements of the list.

1. Merge2Lists: Merges the new list with the old list. New merged list should be sorted in ascending order.

2. 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

1. Delete

1. Find Smallest number

1. Find Largest number

1. Average of numbers

1. Merge2Lists

1. Print

1. Exit

• 7

List: 12 25 27 8 2 57 43 90 4 66 1

——————————————————————————————————————-

Choose one operation from the options below:

1. Insert

1. Delete

1. Find Smallest number

1. Find Largest number

1. Average of numbers

1. Merge2Lists

1. Print

1. Exit

• 1

Enter element to be inserted in list: 5

——————————————————————————————————–

Choose one operation from the options below:

1. Insert

1. Delete

1. Find Smallest number

1. Find Largest number

1. Average of numbers

1. Merge2Lists

1. Print

1. Exit

• 7

List: 12 25 27 8 2 57 43 90 4 66 1 5

—————————————————————————————————————-

Choose one operation from the options below:

1. Insert

1. Delete

1. Find Smallest number

1. Find Largest number

1. Average of numbers

1. Merge2Lists

1. Print

1. Exit

• 1

Enter element to be inserted in list: 27

——————————————————————————————————–

Choose one operation from the options below:

1. Insert

1. Delete

1. Find Smallest number

1. Find Largest number

1. Average of numbers

1. Merge2Lists

1. Print

1. 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

1. Delete

1. Find Smallest number

1. Find Largest number

1. Average of numbers

1. Merge2Lists

1. Print

1. Exit

• 2

Enter the number to be deleted: 43

Delete was successful.

——————————————————————————————————————-

Choose one operation from the options below:

1. Insert

1. Delete

1. Find Smallest number

1. Find Largest number

1. Average of numbers

1. Merge2Lists

1. Print

1. Exit

• 7

List: 12 25 27 8 2 57 90 4 66 1 5 27

———————————————————————————————————————-

Choose one operation from the options below:

1. Insert

1. Delete

1. Find Smallest number

1. Find Largest number

1. Average of numbers

1. Merge2Lists

1. Print

1. Exit

• 2

Enter the number to be deleted: 27

Delete was successful.

——————————————————————————————————————-

Choose one operation from the options below:

1. Insert

1. Delete

1. Find Smallest number

1. Find Largest number

1. Average of numbers

1. Merge2Lists

1. Print

1. Exit

• 7

List: 12 25 8 2 57 90 4 66 1 5 27

———————————————————————————————————————-

Choose one operation from the options below:

1. Insert

1. Delete

1. Find Smallest number

1. Find Largest number

1. Average of numbers

1. Merge2Lists

1. Print

1. Exit

• 2

Enter the number to be deleted: 77

————————————————————————————————————————

Choose one operation from the options below:

1. Insert

1. Delete

1. Find Smallest number

1. Find Largest number

1. Average of numbers

1. Merge2Lists

1. Print

1. Exit

• 3

Smallest number: 1

———————————————————————————————————————

Choose one operation from the options below:

1. Insert

1. Delete

1. Find Smallest number

1. Find Largest number

1. Average of numbers

1. Merge2Lists

1. Print

1. Exit

• 4

Largest number: 90

——————————————————————————————————————-

Choose one operation from the options below:

1. Insert

1. Delete

1. Find Smallest number

1. Find Largest number

1. Average of numbers

1. Merge2Lists

1. Print

1. Exit

• 5

Average: 27

——————————————————————————————————————–

Choose one operation from the options below:

1. Insert

1. Delete

1. Find Smallest number

1. Find Largest number

1. Average of numbers

1. Merge2Lists

1. Print

1. 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:

1. Insert

1. Delete

1. Find Smallest number

1. Find Largest number

1. Average of numbers

1. Merge2Lists

1. Print

1. 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:

1. Insert

1. Delete

1. Find Smallest number

1. Find Largest number

1. Average of numbers

1. Merge2Lists

1. Print

1. 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).

• Your program should run on the Linux machines in Eaton 1005D using g++.

0