CSE 207 - Lab-2
CSE 207 - Lab-2
Objective:
The objective of this lab is to provide basic concept of linked list. At the end of the lab, students
are able:
➢ To learn how to create a linked list
➢ To learn how to insert new nodes in linked list
➢ To learn how to delete a node from linked list.
➢ To learn how to reverse nodes of linked list.
Linked list:
A linked list is a sequence of data structures, which are connected together via links. Linked List
is a sequence of links which contains items. Each link contains a connection to another link.
Linked list is the second most-used data structure after array.
Linked list can be visualized as a chain of nodes, where every node points to the next node.
Page 1 of 3
Now you have to perform the following lab task on linked list:
Exercise 1:
Create a Menu
Create a menu that will display all the exercises given below (Exercise 2 to Exercise 8) as a list
and prompt user to select any desired option. The menu can be designed in below format.
Exercise 2:
Create Linked List
Creating linked list is a more than one step activity. First, create a node using structure and find
the location where it has to be inserted. Then input the data and store it in the allocated
memory space. Use the pointer part of the node to point another node and insert the node at
the end of the previously inserted node.
Exercise 3:
Insert New Node at beginning
After completing exercise 1 you have a newly created linked list. Then take a new node and add
it in the beginning of the linked list.
Exercise 4:
Insert New Node at any position
Take a position number to insert a new node. Then take a new node and add it in the specified
position number.
Exercise 5:
Delete Node from last position
Delete the last node from the linked list and make the pointer part NULL of the previous node
of the last node
Exercise 6:
Delete Node from beginning
Delete the first node.
Page 2 of 3
Exercise 7:
Delete Node from any position
Take a position number to delete a node from that position number.
Exercise 8:
Reverse Linked list
You have to reverse the linked list in following format.
Exercise 9:
Remove Duplicate data from Linked list
You have to remove all duplicate entry from your linked list. For this you have to create a list of
data containing duplicate data and after executing, your program will provide a list, by
removing all duplicate data.
Example:
Input: 1 2 1 1 2 3
Output: 1 2 3
Page 3 of 3