0% found this document useful (0 votes)
23 views

Data Structures Question Set 3

Uploaded by

Kishore Prasad
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Data Structures Question Set 3

Uploaded by

Kishore Prasad
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

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:

 Display the elements of the linked list.


 Display the elements in reverse order.
 Insert the following element 25, 15, 95, 12 at the end of the linked list. Display the
elements of the resulting linked list.
 Remove 2 elements from the beginning of the linked list. Display the elements of the
resulting linked list.
 Insert a new element 37 after the existing linked list element 124. If there are more than
one occurrence of 124, give user the choice where the new element must be inserted.
Display the elements of the resulting linked list.
 Insert a new element 32 before the existing linked list element 25. If there are more
than one occurrence of 25, give user the choice where the new element must be
inserted. Display the elements of the resulting linked list. Print the size of the linked list.
 Insert 6 more elements into the linked list. Display the elements of the resulting linked
list. Print the total number of elements in the linked list.
 Insert an element 84 after the 3rd element in the linked list. Display the elements of the
resulting linked list. Print the total number of elements in the linked list.
 Reverse the existing linked list and create a new 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:

 Regional Vice President


 Vice President
 Technical Director
 Senior Manager
 Manager
 Project Head
 Project Chief Designer
 Project Chief Architect
 Project Chief Solutions Expert
 Senior Programmer
 Junior Programmer
 Senior Designer
 Junior Designer
 Staff
You must use Linked List to store information about all the employees.
Display the name and ID of the employee with the highest salary in the company.
Display the name and ID of the employee with the highest salary in each designation.
The program should have the flexibility to add new employees at any time.

You might also like