Data Structure and Applications Question Bank
Module 2
1. Explain the memory representation of singly linked list.
2. Differentiate the Linked lists and Arrays.
3. Write an algorithm and C function to print values of each node and number of nodes in the
singly linked list.
4. Write an algorithm and C function to search for a value in a singly linked list.
5. Write a ‘C’ function for the following operations of singly linked list.
1. Inserting a New Node at the front of a Linked List.
2. Inserting a Node at the End of a Linked List.
3. Inserting a Node After a Given Node in a Linked List.
4. Inserting a Node Before a Given Node in a Linked List.
5. Insert at a position.
6. Deleting the First Node from a Linked List
7. Deleting the Last Node from a Linked List
8. Delete at a position
9. Delete a key node
10. Delete after a key number
11. Delete before a key number
12. Display the list
6. Write a C program to reverse a linked list elements.
7. Assume we have a linked list that was created using the following structure.
struct student
{
char name[20];
int marks;
struct student *next;
};
Because of a system error, the marks entered by the teacher have been reduced by 5 for all
students.
Write a ‘C’ function to increase the marks of all students by 5. Also display the count of student
present in the list.
8. Write a C function that removes duplicate elements from a sorted singly linked list.
9. Write a C function that calculates and returns the sum of all marks of students in a singly
linked list.
10. Write a C function to sort a singly linked list of students based on their marks in ascending
order.
11. Assume the following `Employee` structure in C:
struct Employee {
int id;
char name[50];
float salary;
struct Employee* next;
};
1. Write a C function to insert an employee's details (`id`, `name`, `salary`) at the beginning of a
singly linked list.
2. Write a function to delete an employee’s details from a singly linked list using the `Employee`
structure, given the employee's `id`.
3. Write a C function to update each employee’s salary to 5000 Rs.
4. Write a C function to count the number of employees stored in the singly linked list.
5. Write a C function to display the employee details.
12. Explain the memory representation of doubly linked list.
13. Write a ‘C’ function for the following operations of doubly linked list.
1. Inserting a New Node at the front of a Linked List.
2. Inserting a Node at the End of a Linked List.
3. Inserting a Node After a Given Node in a Linked List.
4. Inserting a Node Before a Given Node in a Linked List.
5. Insert at a position.
6. Deleting the First Node from a Linked List
7. Deleting the Last Node from a Linked List
8. Delete at a position
9. Delete a key node
10. Delete after a key number
11. Delete before a key number
12. Display the list
14. Assume the following `Car` structure in C:
struct Car {
int id;
char model[50];
float price;
struct Car* prev;
struct Car* next;
};
1. Write a C function to insert a car’s details (`id`, `model`, `price`) at the end of a doubly linked list.
2. Write a function to delete car’s details based on car model from a doubly linked list using the
`Car’s structure.
3. Write a C function to increase each car’s price to 1lakh.
4. Write a C function to count the number of cars detail stored in the doubly linked list.
5. Write a C function to display all cars details.
15. Write an algorithm and C function to insert a new node at the front and end of the circular
singly linked list.
16. Write an algorithm and C function to delete a node at the front and end of the circular singly
linked list.
17. Write an algorithm and C function to insert a new node at the front and end of the circular
doubly linked list.
18. Write an algorithm and C function to delete a node at the front and end of the circular doubly
linked list.
19. Assume the following `BankAccount` structure.
struct BankAccount {
int accountNumber;
char accountHolder[100];
float balance;
struct BankAccount* next;
};
1. Write a C function to insert a new bank account (`accountNumber`, `accountHolder`,
`balance`) at the beginning of a circular singly linked list.
2. Write a function to delete a bank account from the circular singly linked list, given the
`accountNumber`.
3. Write a function to detect if a given singly linked list is circular.
20. Consider the following `BankAccount` structure.
struct BankAccount {
int accountNumber;
char accountHolder[100];
float balance;
struct BankAccount* next;
};
1. Write a C function to insert a new bank account at the end of a circular doubly linked list.
2. Write a C function to delete a last bank account details in circular doubly linked list.
3. Write a function to traverse the list in reverse (from tail to head) and print all bank account details.
4. Write a function to count the number of bank accounts in the circular doubly linked list.