expt6 manual sheets
expt6 manual sheets
Program Statement:
Develop and execute a program in C using suitable data structures to perform searching for a
data item in an ordered list of items in both directions. The program should implement the
following operations:
Theory:
Doubly linked list:
A doubly linked list is a type of linked list where each node contains a data element and two
pointers, one pointing to the next node in the sequence and another pointing to the previous node.
This bidirectional linking allows for easy traversal in both forward and backward directions. The
structure of a doubly linked list node is as follows:
struct Node
};
Searching in an Ordered List:
Searching in an ordered list involves locating a specific data item within the list. In the context of
a doubly linked list, searching can be performed efficiently in both directions—forward and
backward. The list is assumed to be ordered, meaning the elements are arranged in ascending or
descending order based on the data. If the list is not ordered, we sort the list to be in a particular
order
Overall Objective:
The overarching goal of developing and executing a program with these specifications is to
showcase the efficiency of searching in both directions within an ordered doubly linked list. By
implementing operations like insertion at the start and end, the program demonstrates the
flexibility and utility of doubly linked lists in maintaining ordered data and performing searches
with improved time complexity.
int main() {
//Local declaration
do {
printf("1. Create a doubly linked list and insert at front 2. Insert a new node at the end 3.
Display the list 4. Search in the list 5. Sort list 6. Exit");
//read choice from user
switch (choice)
{
case 1: // Function call for creating a linked list and inserting a node at front
break;
case 2:// Function call to insert data at the end of the list
break;
case 3:// Function call to display linked list
break;
------
case 6:
default:
printf("Invalid choice. Please enter a valid option. ");
} // end switch
} while (choice != 6);
}//end main
Output: