Question: Write a program to create a linked list structure. It should support insert and delete operation. To - do: Insert a node with data value

Write a program to create a linked list structure. It should support insert and delete
operation.
To-do:
Insert a node with data value 60 in the first position
Insert a node with data value 40 in the first position.
Insert a node with data value 20 in the first position.
20->40->60
Hint: Create a struct for node with variables data (int) and pointer (struct node type
which keeps track of the next node). Write an insert method which receives the data value as
an argument and creates a node with that data and inserts it in the first position as described
in the algorithm.
Print the linked list elements
Hint: Traverse the linked list till it reaches null and print the data.
Delete the first element of the linked list and print the linked list
40->60
Hint: Create a temporary node to store the head and then point head to the second element.
Delete the last element of the linked list and print the linked list
40
Hint: Traverse till last but one node in the linCSkCeI 1d15list and set the pointer of that node 18

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!