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

Data stractureande Algorithm linked list

The document is an individual assignment by Natnael Gulma on Data Structures and Algorithms, specifically focusing on implementing operations for Doubly Linked Lists and Singly Circular Linked Lists in C++. It includes detailed C++ code for various operations such as insertion, deletion, sorting, and searching of student records. The assignment is submitted to Mr. Kibru G. on May 5, 2025, in Haramaya, Ethiopia.

Uploaded by

natigulam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Data stractureande Algorithm linked list

The document is an individual assignment by Natnael Gulma on Data Structures and Algorithms, specifically focusing on implementing operations for Doubly Linked Lists and Singly Circular Linked Lists in C++. It includes detailed C++ code for various operations such as insertion, deletion, sorting, and searching of student records. The assignment is submitted to Mr. Kibru G. on May 5, 2025, in Haramaya, Ethiopia.

Uploaded by

natigulam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

Data Structures and Algorithms

Individual Assignment One

NAME: NATNAEL GULMA


ID: 2172/16
SECTION:1

Submitted To Mr . KIBRU G.
Haramaya, Ethiopia
MAY 5. 2025GC

1
Data Structures and Algorithms
Individual Assignment One
1. Write a C++ program to implement the following operations on Doubly Linked List.
a. Insert element at the beginning
b. Insert element at the End
c. Insert element at the Middle
d. Delete element at the beginning
e. Delete element at the End
f. Delete element at the Middle
g. Sort elements of the list in ascending and/or descending order
h. Search an Element on a Linked List
 ANSWER for StudentInfo (BY Doubly Linked List)

#include <iostream>
#include <string>
using namespace std;

struct StudentInfo {
int ID;
string name;
char sex;
string college;
string dept;
int classYear;
int semester;
int section;
float cgpa;
StudentInfo* next;
StudentInfo* prev;
};

StudentInfo* head = nullptr;

StudentInfo inputStudent() {
StudentInfo s;
cout << "Enter Student Details:\n";
cout << "ID: "; cin >> s.ID;
cout << "Name: "; cin >> s.name;
cout << "Sex: "; cin >> s.sex;
cout << "College: "; cin >> s.college;
cout << "Department: "; cin >> s.dept;
cout << "Class Year: "; cin >> s.classYear;
cout << "Semester: "; cin >> s.semester;
cout << "Section: "; cin >> s.section;
cout << "CGPA: "; cin >> s.cgpa;
s.next = s.prev = nullptr;
return s;
}

void insertAtBeginning(StudentInfo s) {
StudentInfo* newNode = new StudentInfo(s);
if (!head) {
head = newNode;
} else {

2
newNode->next = head;
head->prev = newNode;
head = newNode;
}
cout << "Inserted at beginning.\n";
}

void insertAtEnd(StudentInfo s) {
StudentInfo* newNode = new StudentInfo(s);
if (!head) {
head = newNode;
} else {
StudentInfo* temp = head;
while (temp->next)
temp = temp->next;
temp->next = newNode;
newNode->prev = temp;
}
cout << "Inserted at end.\n";
}

void insertAtMiddle(StudentInfo s, int position) {


if (position <= 1) {
insertAtBeginning(s);
return;
}
StudentInfo* newNode = new StudentInfo(s);
StudentInfo* temp = head;
int index = 1;
while (index < position - 1 && temp->next) {
temp = temp->next;
index++;
}
newNode->next = temp->next;
newNode->prev = temp;
if (temp->next)
temp->next->prev = newNode;
temp->next = newNode;
cout << "Inserted at position " << position << ".\n";
}

void deleteAtBeginning() {
if (!head) {
cout << "List is empty.\n";
return;
}
StudentInfo* temp = head;
head = head->next;
if (head)
head->prev = nullptr;
delete temp;
cout << "Deleted from beginning.\n";
}

void deleteAtEnd() {
if (!head) {
cout << "List is empty.\n";

3
return;
}
StudentInfo* temp = head;
if (!temp->next) {
delete temp;
head = nullptr;
} else {
while (temp->next)
temp = temp->next;
temp->prev->next = nullptr;
delete temp;
}
cout << "Deleted from end.\n";
}

void deleteAtMiddle(int position) {


if (!head || position <= 1) {
deleteAtBeginning();
return;
}
StudentInfo* temp = head;
int index = 1;
while (index < position && temp) {
temp = temp->next;
index++;
}
if (!temp) {
cout << "Invalid position.\n";
return;
}
if (temp->prev)
temp->prev->next = temp->next;
if (temp->next)
temp->next->prev = temp->prev;
delete temp;
cout << "Deleted at position " << position << ".\n";
}

void sortList(bool ascending = true) {


if (!head || !head->next) return;
for (StudentInfo* i = head; i->next; i = i->next) {
for (StudentInfo* j = i->next; j; j = j->next) {
if ((ascending && i->ID > j->ID) || (!ascending && i->ID < j->ID)) {
swap(i->ID, j->ID);
swap(i->name, j->name);
swap(i->sex, j->sex);
swap(i->college, j->college);
swap(i->dept, j->dept);
swap(i->classYear, j->classYear);
swap(i->semester, j->semester);
swap(i->section, j->section);
swap(i->cgpa, j->cgpa);
}
}
}
cout << "List sorted in " << (ascending ? "ascending" : "descending") << " order.\n";
}

4
void searchByID(int id) {
if (!head) {
cout << "List is empty.\n";
return;
}
StudentInfo* temp = head;
while (temp) {
if (temp->ID == id) {
cout << "\nStudent Found:\n";
cout << "ID: " << temp->ID << "\nName: " << temp->name
<< "\nSex: " << temp->sex << "\nCollege: " << temp->college
<< "\nDepartment: " << temp->dept << "\nClass Year: " << temp->classYear
<< "\nSemester: " << temp->semester << "\nSection: " << temp->section
<< "\nCGPA: " << temp->cgpa << endl;
return;
}
temp = temp->next;
}
cout << "Student not found.\n";
}

void displayAll() {
if (!head) {
cout << "List is empty.\n";
return;
}
StudentInfo* temp = head;
cout << "\nAll Student Records:\n";
while (temp) {
cout << "----------------------------\n";
cout << "ID: " << temp->ID
<< "\nName: " << temp->name
<< "\nSex: " << temp->sex
<< "\nCollege: " << temp->college
<< "\nDepartment: " << temp->dept
<< "\nClass Year: " << temp->classYear
<< "\nSemester: " << temp->semester
<< "\nSection: " << temp->section
<< "\nCGPA: " << temp->cgpa << "\n";
temp = temp->next;
}
}

int main() {
int choice, position, id;
StudentInfo s;
while (true) {
cout << "\n->Student Management System (By Doubly Linked List)<-\n"
<< "1. Insert Student at the beginning\n"
<< "2. Insert Student at the End\n"
<< "3. Insert Student at the Middle\n"
<< "4. Delete Student at the beginning\n"
<< "5. Delete Student at the End\n"
<< "6. Delete Student at the Middle\n"
<< "7. Sort Student list in ascending order\n"
<< "8. Sort Student list in descending order\n"

5
<< "9. Search Student by ID\n"
<< "10. Display All\n"
<< "11. Exit\n"
<< "----------------------------------\n"
<< "Enter your choice: ";
cin >> choice;
switch (choice) {
case 1:
s = inputStudent();
insertAtBeginning(s);
break;
case 2:
s = inputStudent();
insertAtEnd(s);
break;
case 3:
s = inputStudent();
cout << "Enter position: ";
cin >> position;
insertAtMiddle(s, position);
break;
case 4:
deleteAtBeginning();
break;
case 5:
deleteAtEnd();
break;
case 6:
cout << "Enter position: ";
cin >> position;
deleteAtMiddle(position);
break;
case 7:
sortList(true);
break;
case 8:
sortList(false);
break;
case 9:
cout << "Enter ID to search: ";
cin >> id;
searchByID(id);
break;
case 10:
displayAll();
break;
case 11:
return 0;
default:
cout << "Invalid choice.\n";
}
}
return 0;
}
--------------------------------------------END OF CODE PART 1-----------------------------------------------------
--

6
2. Write a C++ program to implement the following operations on Singly Circular Linked List.
a. Insert element at the beginning
b. Insert element at the End
c. Insert element at the Middle
d. Delete element at the beginning
e. Delete element at the End
f. Delete element at the Middle
g. Sort elements of the list in ascending and/or descending order
h. Search an Element on a Linked List.
 ANSWER for StudentInfo (BY Singly Circular Linked List.)
#include <iostream>
#include <string>
using namespace std;

struct studentInfo {
int ID;
string name;
char sex;
string college;
string dept;
int classYear;
int semester;
int section;
float cgpa;
studentInfo* next;
};

studentInfo* head = nullptr;

studentInfo inputStudent() {
studentInfo s;
cout << "Enter Student Details:\n";
cout << "ID: "; cin >> s.ID;
cout << "Name: "; cin >> s.name;
cout << "Sex: "; cin >> s.sex;
cout << "College: "; cin >> s.college;
cout << "Department: "; cin >> s.dept;
cout << "Class Year: "; cin >> s.classYear;
cout << "Semester: "; cin >> s.semester;
cout << "Section: "; cin >> s.section;
cout << "CGPA: "; cin >> s.cgpa;
s.next = nullptr;
return s;
}

void insertAtBeginning(studentInfo s) {
studentInfo* newNode = new studentInfo(s);
if (!head) {
head = newNode;
newNode->next = head;
} else {
studentInfo* temp = head;
while (temp->next != head)
temp = temp->next;
temp->next = newNode;
newNode->next = head;
head = newNode;

7
}
cout << "Inserted at beginning.\n";
}

void insertAtEnd(studentInfo s) {
studentInfo* newNode = new studentInfo(s);
if (!head) {
head = newNode;
newNode->next = head;
} else {
studentInfo* temp = head;
while (temp->next != head)
temp = temp->next;
temp->next = newNode;
newNode->next = head;
}
cout << "Inserted at end.\n";
}

void insertAtMiddle(studentInfo s, int position) {


if (position <= 1) {
insertAtBeginning(s);
return;
}
studentInfo* temp = head;
int index = 1;
while (index < position - 1 && temp->next != head) {
temp = temp->next;
index++;
}
studentInfo* newNode = new studentInfo(s);
newNode->next = temp->next;
temp->next = newNode;
cout << "Inserted at position " << position << ".\n";
}

void deleteAtBeginning() {
if (!head) {
cout << "List is empty.\n";
return;
}
if (head->next == head) {
delete head;
head = nullptr;
} else {
studentInfo* temp = head;
studentInfo* last = head;
while (last->next != head)
last = last->next;
head = head->next;
last->next = head;
delete temp;
}
cout << "Deleted from beginning.\n";
}

void deleteAtEnd() {

8
if (!head) {
cout << "List is empty.\n";
return;
}
if (head->next == head) {
delete head;
head = nullptr;
} else {
studentInfo* temp = head;
studentInfo* prev = nullptr;
while (temp->next != head) {
prev = temp;
temp = temp->next;
}
prev->next = head;
delete temp;
}
cout << "Deleted from end.\n";
}

void deleteAtMiddle(int position) {


if (!head || position <= 1) {
deleteAtBeginning();
return;
}
studentInfo* temp = head;
studentInfo* prev = nullptr;
int index = 1;
while (index < position && temp->next != head) {
prev = temp;
temp = temp->next;
index++;
}
if (temp == head) {
cout << "Invalid position.\n";
return;
}
prev->next = temp->next;
delete temp;
cout << "Deleted at position " << position << ".\n";
}

void sortList(bool ascending = true) {


if (!head || head->next == head) return;
for (studentInfo* i = head; i->next != head; i = i->next) {
for (studentInfo* j = i->next; j != head; j = j->next) {
if ((ascending && i->ID > j->ID) || (!ascending && i->ID < j->ID)) {
swap(i->ID, j->ID);
swap(i->name, j->name);
swap(i->sex, j->sex);
swap(i->college, j->college);
swap(i->dept, j->dept);
swap(i->classYear, j->classYear);
swap(i->semester, j->semester);
swap(i->section, j->section);
swap(i->cgpa, j->cgpa);
}

9
}
}
cout << "List sorted in " << (ascending ? "ascending" : "descending") << " order.\n";
}

void searchByID(int id) {


if (!head) {
cout << "List is empty.\n";
return;
}
studentInfo* temp = head;
do {
if (temp->ID == id) {
cout << "\nStudent Found:\n";
cout << "ID: " << temp->ID << "\nName: " << temp->name
<< "\nSex: " << temp->sex << "\nCollege: " << temp->college
<< "\nDepartment: " << temp->dept << "\nClass Year: " << temp->classYear
<< "\nSemester: " << temp->semester << "\nSection: " << temp->section
<< "\nCGPA: " << temp->cgpa << endl;
return;
}
temp = temp->next;
} while (temp != head);
cout << "Student not found.\n";
}

void displayAll() {
if (!head) {
cout << "List is empty.\n";
return;
}
studentInfo* temp = head;
cout << "\nAll Student Records:\n";
do {
cout << "----------------------------\n";
cout << "ID: " << temp->ID
<< "\nName: " << temp->name
<< "\nSex: " << temp->sex
<< "\nCollege: " << temp->college
<< "\nDepartment: " << temp->dept
<< "\nClass Year: " << temp->classYear
<< "\nSemester: " << temp->semester
<< "\nSection: " << temp->section
<< "\nCGPA: " << temp->cgpa << "\n";
temp = temp->next;
} while (temp != head);
}
int main() {
int choice, position, id;
studentInfo s;
while (true) {
cout << "\n--- Student Management System ---\n"
<< "1. Insert Student at the beginning\n"
<< "2. Insert Student at the End\n"
<< "3. Insert Student at the Middle\n"
<< "4. Delete Student at the beginning\n"
<< "5. Delete Student at the End\n"

10
<< "6. Delete Student at the Middle\n"
<< "7. Sort Student list in ascending order\n"
<< "8. Sort Student list in descending order\n"
<< "9. Search Student by ID\n"
<< "10. Display All\n"
<< "11. Exit\n"
<< "----------------------------------\n"
<< "Enter your choice: ";
cin >> choice;
switch (choice) {
case 1:
s = inputStudent();
insertAtBeginning(s);
break;
case 2:
s = inputStudent();
insertAtEnd(s);
break;
case 3:
s = inputStudent();
cout << "Enter position: ";
cin >> position;
insertAtMiddle(s, position);
break;
case 4:
deleteAtBeginning();
break;
case 5:
deleteAtEnd();
break;
case 6:
cout << "Enter position: ";
cin >> position;
deleteAtMiddle(position);
break;
case 7:
sortList(true);
break;
case 8:
sortList(false);
break;
case 9:
cout << "Enter ID to search: ";
cin >> id;
searchByID(id);
break;
case 10:
displayAll();
break;
case 11:
return 0;
default:
cout << "Invalid choice.\n";
}
}
return 0;
}

11
--------------------------------------------END OF CODE PART 2---------------------------------------------------
3.Write a C++ program to implement the following operations on Doubly Circular Linked List.
a. Insert element at the beginning
b. Insert element at the End
c. Insert element at the Middle
d. Delete element at the beginning
e. Delete element at the End
f. Delete element at the Middle
g. Sort elements of the list in ascending and/or descending order
h. Search an Element on a Linked List

 ANSWER for StudentInfo (BY Doubly Circular Linked List)

#include <iostream>
#include <string>
using namespace std;

struct SthdentInfo {
int ID;
string name;
char sex;
string college;
string dept;
int classYear;
int semester;
int section;
float cgpa;
SthdentInfo* next;
SthdentInfo* prev;
};

SthdentInfo* head = nullptr;

SthdentInfo inputSthdentInfo() {
SthdentInfo s;
cout << "Enter Student Details:\n";
cout << "ID: "; cin >> s.ID;
cout << "Name: "; cin >> s.name;
cout << "Sex: "; cin >> s.sex;
cout << "College: "; cin >> s.college;
cout << "Department: "; cin >> s.dept;
cout << "Class Year: "; cin >> s.classYear;
cout << "Semester: "; cin >> s.semester;
cout << "Section: "; cin >> s.section;
cout << "CGPA: "; cin >> s.cgpa;
s.next = s.prev = nullptr;
return s;

12
}

void insertAtBeginning(SthdentInfo s) {
SthdentInfo* newNode = new SthdentInfo(s);
if (!head) {
head = newNode;
newNode->next = newNode->prev = newNode;
} else {
SthdentInfo* tail = head->prev;
newNode->next = head;
newNode->prev = tail;
head->prev = newNode;
tail->next = newNode;
head = newNode;
}
cout << "Inserted at beginning.\n";
}

void insertAtEnd(SthdentInfo s) {
SthdentInfo* newNode = new SthdentInfo(s);
if (!head) {
head = newNode;
newNode->next = newNode->prev = newNode;
} else {
SthdentInfo* tail = head->prev;
tail->next = newNode;
newNode->prev = tail;
newNode->next = head;
head->prev = newNode;
}
cout << "Inserted at end.\n";
}

void insertAtMiddle(SthdentInfo s, int position) {


if (position <= 1 || !head) {
insertAtBeginning(s);
return;
}
SthdentInfo* temp = head;
int index = 1;
while (index < position - 1 && temp->next != head) {
temp = temp->next;
index++;
}
SthdentInfo* newNode = new SthdentInfo(s);
newNode->next = temp->next;
newNode->prev = temp;
temp->next->prev = newNode;
temp->next = newNode;
cout << "Inserted at position " << position << ".\n";
}

void deleteAtBeginning() {
if (!head) {
cout << "List is empty.\n";
return;
}

13
if (head->next == head) {
delete head;
head = nullptr;
} else {
SthdentInfo* tail = head->prev;
SthdentInfo* temp = head;
head = head->next;
head->prev = tail;
tail->next = head;
delete temp;
}
cout << "Deleted from beginning.\n";
}

void deleteAtEnd() {
if (!head) {
cout << "List is empty.\n";
return;
}
if (head->next == head) {
delete head;
head = nullptr;
} else {
SthdentInfo* tail = head->prev;
SthdentInfo* newTail = tail->prev;
newTail->next = head;
head->prev = newTail;
delete tail;
}
cout << "Deleted from end.\n";
}

void deleteAtMiddle(int position) {


if (!head || position <= 1) {
deleteAtBeginning();
return;
}
SthdentInfo* temp = head;
int index = 1;
while (index < position && temp->next != head) {
temp = temp->next;
index++;
}
if (temp == head) {
cout << "Invalid position.\n";
return;
}
temp->prev->next = temp->next;
temp->next->prev = temp->prev;
delete temp;
cout << "Deleted at position " << position << ".\n";
}

void sortList(bool ascending = true) {


if (!head || head->next == head) return;
for (SthdentInfo* i = head; i->next != head; i = i->next) {
for (SthdentInfo* j = i->next; j != head; j = j->next) {

14
if ((ascending && i->ID > j->ID) || (!ascending && i->ID < j->ID)) {
swap(i->ID, j->ID);
swap(i->name, j->name);

swap(i->sex, j->sex);
swap(i->college, j->college);
swap(i->dept, j->dept);
swap(i->classYear, j->classYear);
swap(i->semester, j->semester);
swap(i->section, j->section);
swap(i->cgpa, j->cgpa);
}
}
}
cout << "List sorted in " << (ascending ? "ascending" : "descending") << " order.\n";
}

void searchByID(int id) {


if (!head) {
cout << "List is empty.\n";
return;
}
SthdentInfo* temp = head;
do {
if (temp->ID == id) {
cout << "\nStudent Found:\n";
cout << "ID: " << temp->ID << "\nName: " << temp->name
<< "\nSex: " << temp->sex << "\nCollege: " << temp->college
<< "\nDepartment: " << temp->dept << "\nClass Year: " << temp->classYear
<< "\nSemester: " << temp->semester << "\nSection: " << temp->section
<< "\nCGPA: " << temp->cgpa << endl;
return;
}
temp = temp->next;
} while (temp != head);
cout << "Student not found.\n";
}

void displayAll() {
if (!head) {
cout << "List is empty.\n";
return;
}
SthdentInfo* temp = head;
cout << "\nAll Student Records:\n";
do {
cout << "----------------------------\n";
cout << "ID: " << temp->ID
<< "\nName: " << temp->name
<< "\nSex: " << temp->sex
<< "\nCollege: " << temp->college
<< "\nDepartment: " << temp->dept
<< "\nClass Year: " << temp->classYear
<< "\nSemester: " << temp->semester
<< "\nSection: " << temp->section
<< "\nCGPA: " << temp->cgpa << "\n";
temp = temp->next;

15
} while (temp != head);
}

int main() {
int choice, position, id;
SthdentInfo s;
while (true) {
cout << "\n--- Student Management System (Doubly Circular Linked List) ---\n"
<< "1. Insert Student at the beginning\n"
<< "2. Insert Student at the End\n"
<< "3. Insert Student at the Middle\n"
<< "4. Delete Student at the beginning\n"
<< "5. Delete Student at the End\n"
<< "6. Delete Student at the Middle\n"
<< "7. Sort Student list in ascending order\n"
<< "8. Sort Student list in descending order\n"
<< "9. Search Student by ID\n"
<< "10. Display All\n"
<< "11. Exit\n"
<< "----------------------------------\n"
<< "Enter your choice: ";
cin >> choice;
switch (choice) {
case 1:
s = inputSthdentInfo();
insertAtBeginning(s);
break;
case 2:
s = inputSthdentInfo();
insertAtEnd(s);
break;
case 3:
s = inputSthdentInfo();
cout << "Enter position: ";
cin >> position;
insertAtMiddle(s, position);
break;
case 4:
deleteAtBeginning();
break;
case 5:
deleteAtEnd();
break;
case 6:
cout << "Enter position: ";
cin >> position;
deleteAtMiddle(position);
break;
case 7:
sortList(true);
break;
case 8:
sortList(false);
break;
case 9:
cout << "Enter ID to search: ";
cin >> id;

16
searchByID(id);
break;
case 10:
displayAll();
break;
case 11:
return 0;
default:
cout << "Invalid choice.\n";
}
}
return 0;
}
4. Briefly discuss the applications of linked list:
a. Singly Linked List
b. Doubly Linked List
c. Circular Linked Lis

What is a Linked List ?

A linked list is a linear data structure. It is a collection of nodes, and a node


contains data and addresses the next node. Linked lists do not use contiguous memory
allocation for storage, unlike arrays.

What are the Applications of Linked List ?

 There are many applications of linked lists, be it in computer science or the real
world.

Some of these Applications are :

1. Applications of Linked List in Computer Science :

 Linked lists can be used to represent polynomials.


 Using a linked list, we can perform the polynomial manipulation.
 Arithmetic operations like addition or subtraction of long integers can also be performed
using a linked list.
 The linked list can be used to implement stacks and queues.
 The linked list is also used in implementing graphs in which the adjacent vertices are stored in
the nodes of the linked list popularly known as Adjacency list representation.
2. Applications of Linked Lists in the Real World :

 In music players, we can create our song playlist and can play a song either from starting or
ending of the list. And these music players are implemented using a linked list.
 We watch the photos on our laptops or PCs, and we can simply see
the next or previous images easily. This feature is implemented using a linked list.
 You must be reading this article on your web browser, and in web browsers, we open multiple
URLs, and we can easily switch between those URLs using the previous and next buttons
because they are connected using a linked list.

17
A. ) Singly Linked List :

A singly linked list is a linear data structure in which each node contains two
elements: the data and a pointer (or reference) to the next node in the sequence.
The last node in the list points to null, indicating the end of the list.

Applications of Singly Linked Lists:

 The singly linked list is used to implement stack and queue.


 The undo or redo options, the back buttons, etc., that we discussed above are implemented
using a singly linked list.
 During the implementation of a hash function, there arises a problem of collision, to deal
with this problem, a singly linked list is used.
B. ) Doubly Linked Lists :

A doubly linked list is a more flexible version of a singly linked list, where each
node contains three elements: the data, a pointer to the next node, and a pointer
to the previous node. This bidirectional structure allows traversal in both
directions (forward and backward).

Applications of Doubly Linked Lists:

 The doubly linked list is used to implement data structures like a stack, queue, binary
tree, and hash table.
 It is also used in algorithms of LRU (Least Recently used) and MRU(Most Recently Used)
cache.
 The undo and redo buttons can be implemented using a doubly-linked list.
 The doubly linked list can also be used in the allocation and deallocation of memory.

C. ) Circular Linked Lists :

In a circular linked list, the last node in the list points back to the first node instead
of null, forming a closed loop. Circular linked lists can be singly or doubly linked and
are particularly useful in applications that require continuous cycling through
elements.

Applications of Circular Linked Lists:

 The circular linked list can be used to implement queues.


 In web browsers, the back button is implemented using a circular linked list.
 In an operating system, a circular linked list can be used in scheduling algorithms like
the Round Robin algorithm.
 The undo functionality that is present in applications like photo editors etc., is
implemented using circular linked lists.
 Circular linked lists can also be used to implement advanced data structures
like MRU (Most Recently Used) lists and Fibonacci heap.

18

You might also like