Data Structures Question Set 3
Data Structures Question Set 3
Question 1
Write a C program to create a singly linked list. Insert 6 elements into it, make sure one of the
entered elements is 124. Do the following operations on the singly linked list:
Question 2
Write a C program to create a singly linked list. Insert 8 elements into it, make sure one of the
entered elements is 92. Do the following operations on the singly linked list:
Delete the last element in the linked list. Display the elements of the resulting linked list.
Print the total number of elements in the linked list.
Delete the 5th element in the linked list. Display the elements of the resulting linked list.
Print the total number of elements in the linked list.
Display the 5th element in the linked list.
Insert the following elements 25, 15, 95, 12, 45, 11, 30 into the linked list after element
92. Display the elements of the resulting linked list.
Delete one element before 92. If there are more than one occurrence of 92, give user
the choice where the element must be deleted from. Display the elements of the
resulting linked list. Print the total number of elements in the linked list.
Delete the first element of the linked list. Display the elements of the resulting linked
list. Print the total number of elements in the linked list.
Delete one element after 15. If there are more than one occurrence of 15, give user the
choice where the element must be deleted from. Display the elements of the resulting
linked list. Print the total number of elements in the linked list.
Delete two elements after 25. If there are more than one occurrence of 25, give user the
choice where the element must be deleted from. Display the elements of the resulting
linked list. Print the total number of elements in the linked list.
Delete ‘n’ elements after 25. If there are more than one occurrence of 25, give user the
choice where the element must be deleted from. Display the elements of the resulting
linked list. Print the total number of elements in the linked list.
Question 3
Write a C program to read two linked lists from the user. Create another linked list by merging
both the linked lists entered by the user. Display the elements of the resulting linked list. Print
the total number of elements in the linked list.
Question 4
Write a C program to read two linked lists from the user. Make sure the elements of both
linked lists are entered in ascending order. Now you have two linked lists each of which are
sorted in ascending order. Do the following operation:
Merge the two linked lists, the resulting linked must be in ascending order.
Question 5
Write a C program to create a singly linked list and read 6 elements into them. Give the
following choices to the user:
Insert an element.
o Insert at the beginning.
o Insert at the end.
o Insert after a specific element. If there are more than one occurrence of that
element, consult the user for further instructions.
o Insert before a specific element. If there are more than one occurrence of that
element, consult the user for further instructions.
o Insert after a specific element. If there are more than one occurrence of that
element, consult the user for further instructions.
o Insert an element at a given position.
Insert more than one element before/after a specific element. If there are more than
one occurrence of that element, consult the user for further instructions.
Traversal
o Display the elements of the linked list.
o Find the largest number/numbers in the linked list.
o Find the smallest number/numbers in the linked list.
o Find the third largest number/numbers in the linked list.
o Find the second smallest number/numbers in the linked list.
o Display the linked list in reverse order.
Delete an element
o Delete at the beginning.
o Delete at the end.
o Delete after a specific element. If there are more than one occurrence of that
element, consult the user for further instructions.
o Delete before a specific element. If there are more than one occurrence of that
element, consult the user for further instructions.
o Delete an element at a given position.
Delete more than one element before/after a specific element.
Question 6
Write a C program to read two linked lists from the user. Make sure the elements of both
linked lists are entered in descending order. Now you have two linked lists each of which are
sorted in descending order. Do the following operation:
Merge the two linked lists, the resulting linked must be in descending order.
Question 7
Write a C program to read to accept two singly linked lists from the user, make sure some of
the elements are repeated in both the linked lists. Make a third singly linked list containing
those elements that are common in both the lists initially entered by the user.
Question 8
Write a C program to store the name, address, age, employee ID, salary, designation of all
employees in a company. The designation can be any of the following: