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

ds[1]

The document outlines the development of a phone directory application using doubly linked lists, guided by Dr. Mamta P. Wagh at C.V. Raman Global University. It explains the importance of data structures, particularly doubly linked lists, in efficiently managing contact information through operations such as adding, deleting, searching, and displaying contacts. The project demonstrates the practical application of data structures in software development, emphasizing their role in simplifying problem-solving.
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)
6 views

ds[1]

The document outlines the development of a phone directory application using doubly linked lists, guided by Dr. Mamta P. Wagh at C.V. Raman Global University. It explains the importance of data structures, particularly doubly linked lists, in efficiently managing contact information through operations such as adding, deleting, searching, and displaying contacts. The project demonstrates the practical application of data structures in software development, emphasizing their role in simplifying problem-solving.
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/ 20

C.V.

RAMAN GLOBAL UNIVERSITY


BHUBANESWAR, ODISHA
Report in the Topic:-
Develop a phone directory application using doubly
linked lists.
GUIDED BY:-
Dr. Mamta p. Wagh
(Department of CSE)

Sl No Name Contact Regd no Mail id


1 ABHISHEK 7735251298 2401020738 2401020738@cg
PANDEY u-odisha.ac.in
2 SATYAJIT 8917610315 2401020747 2401020747@cg
ROUT u-odisha.ac.in
3 BABLU 7759869976 2401020761 2401020761@cg
KUMAR u-odisha.ac.in
MANDAL
4 BARSA 2401020814 2401020814@cg
PRIYADARSIN u-odisha.ac.in
I SINGH

5
INDEX
What is Data Structure ?
A dAtA structure is A wAy of orgAnizing,
storing, And mAnAging dAtA efficiently so
thAt it cAn be Accessed And modified
eAsily. different dAtA structures Are
designed for different types of tAsks, And
choosing the right one cAn improve the
efficiency of An Algorithm.

Need for Data Structures:-


dAtA structures Are essentiAl in
computer science And softwAre
development becAuse they provide
efficient wAys to orgAnize, mAnAge, And
process dAtA. here Are some key reAsons
why dAtA structures Are needed:
➢ efficient dAtA storAge And retrievAl.
➢ optimized performAnce.
➢ better memory mAnAgement.
➢ fAster execution of progrAms.
➢ scAlAbility And lArge dAtA hAndling.
Type of data Structure:-
Types of Data Structures
Data structures can be broadly classified into
two types:
➢ Linear Data Structures
➢ Non-Linear Data Structures

Linear Data Structures:-


In linear data structures, elements are
arranged in a sequential order. They
are easy to implement and allow
traversal in a single run.

➢ Arrays
➢ Linked Lis
➢ Stack
➢ Queue

Non-Linear Data Structures:-


In non-linear data structures, elements are
not arranged sequentially. They are
connected in a hierarchical or complex
manner.
➢ Trees
➢ Graphs
INTRODUCTION TO DOUBLY LINKED
LIST:-
A doubly linked list (dll) is A type of
linked list in which eAch node contAins
three components:
1. dAtA – stores the ActuAl dAtA.
2. pointer to the next node (next) –
points to the next node in the list.
3. pointer to the previous node (prev) –
points to the previous node in the list.
this structure Allows trAversAl in both
forwArd And bAckwArd directions, mAking
it more flexible thAn A singly linked list,
where movement is only forwArd.
Representation of Doubly Linked List
in Data Structure:-
A doubly linked list (dll) is represented
using nodes, where eAch node contAins
three fields:
1. dAtA – the ActuAl vAlue stored in the
node.
2. pointer to the next node (next) –
points to the next node in the list.
3. pointer to the previous node (prev) –
points to the previous node in the list.
DESIGNING THE PHONE DIRECTORY
APPLICATION:-
Introduction:-
A phone directory is An essentiAl
ApplicAtion thAt Allows users to store,
seArch, updAte, And delete contAct
informAtion efficiently. this cAse study
explores the implementAtion of A phone
directory using A doubly linked list (dll),
highlighting its AdvAntAges in dynAmic
memory AllocAtion.
Objective:-
➢ to develop An efficient phone
directory system using A doubly linked
list.
➢ to enAble users to Add, delete,
seArch, And updAte contActs.
➢ to ensure efficient memory
mAnAgement And fAst trAversAl.
➢ to AnAlyze the benefits of using
doubly linked lists over other dAtA
structures.
Application includes the following
operations:-
✓ Adding A contAct: inserts A new
contAct into the list, mAintAining
AlphAbeticAl order.
✓ deleting A contAct: seArches for A
contAct And removes it from the list.
✓ seArching A contAct: finds A contAct
by nAme And displAys detAils.
✓ updAting A contAct: modifies the
detAils of An existing contAct.
✓ displAying contActs: lists All
contActs in sorted order.
#include <stdio.h>

#include <stdlib.h>

#include <string.h>

// Structure for a Contact Node

struct Contact {

char name[50];

char phone[15];

struct Contact* prev;

struct Contact* next;

};

// Head pointer for the DLL

struct Contact* head = NULL;

// Function to create a new contact node

struct Contact* createContact(char name[], char phone[])


{

struct Contact* newContact = (struct


Contact*)malloc(sizeof(struct Contact));

strcpy(newContact->name, name);

strcpy(newContact->phone, phone);

newContact->prev = NULL;

newContact->next = NULL;

return newContact;
}

// Function to add a contact at the end

void addContact(char name[], char phone[]) {

struct Contact* newContact = createContact(name,


phone);

if (head == NULL) {

head = newContact;

} else {

struct Contact* temp = head;

while (temp->next != NULL) {

temp = temp->next;

temp->next = newContact;

newContact->prev = temp;

printf("Contact Added Successfully!\n");

// Function to display all contacts

void displayContacts() {

if (head == NULL) {

printf("Phone Directory is empty!\n");

return;
}

struct Contact* temp = head;

printf("\nPhone Directory:\n");

while (temp != NULL) {

printf("Name: %s | Phone: %s\n", temp->name, temp-


>phone);

temp = temp->next;

// Function to search for a contact

void searchContact(char name[]) {

if (head == NULL) {

printf("Phone Directory is empty!\n");

return;

struct Contact* temp = head;

while (temp != NULL) {

if (strcmp(temp->name, name) == 0) {

printf("Contact Found: %s | Phone: %s\n", temp-


>name, temp->phone);

return;

}
temp = temp->next;

printf("Contact Not Found!\n");

// Function to delete a contact by name

void deleteContact(char name[]) {

if (head == NULL) {

printf("Phone Directory is empty!\n");

return;

struct Contact* temp = head;

// Find the contact to delete

while (temp != NULL && strcmp(temp->name, name) !=


0) {

temp = temp->next;

if (temp == NULL) {

printf("Contact Not Found!\n");

return;

}
// If the contact to delete is the head

if (temp == head) {

head = head->next;

if (head != NULL) head->prev = NULL;

// If the contact is in the middle or at the end

else {

if (temp->next != NULL) {

temp->next->prev = temp->prev;

if (temp->prev != NULL) {

temp->prev->next = temp->next;

free(temp);

printf("Contact Deleted Successfully!\n");

// Main function to run the Phone Directory application

int main() {

int choice;

char name[50], phone[15];


do {

printf("\nPhone Directory Menu:\n");

printf("1. Add Contact\n");

printf("2. Display Contacts\n");

printf("3. Search Contact\n");

printf("4. Delete Contact\n");

printf("5. Exit\n");

printf("Enter your choice: ");

scanf("%d", &choice);

getchar(); // To clear the buffer

switch (choice) {

case 1:

printf("Enter Name: ");

fgets(name, 50, stdin);

name[strcspn(name, "\n")] = 0; // Remove newline


character

printf("Enter Phone Number: ");

fgets(phone, 15, stdin);

phone[strcspn(phone, "\n")] = 0; // Remove


newline character
addContact(name, phone);

break;

case 2:

displayContacts();

break;

case 3:

printf("Enter Name to Search: ");

fgets(name, 50, stdin);

name[strcspn(name, "\n")] = 0;

searchContact(name);

break;

case 4:

printf("Enter Name to Delete: ");

fgets(name, 50, stdin);

name[strcspn(name, "\n")] = 0;

deleteContact(name);

break;

case 5:
printf("Exiting Phone Directory. Goodbye!\n");

break;

default:

printf("Invalid choice! Please try again.\n");

} while (choice != 5);

return 0;

}
Output:-
Conclusion:-
the development of A phone directory
ApplicAtion using doubly linked lists
demonstrAtes the prActicAl ApplicAtion
of this dAtA structure. by leverAging the
bidirectionAl nAture of doubly linked
lists, the ApplicAtion efficiently
performs operAtions like Adding,
deleting, seArching, And displAying
contActs. this project highlights how
dAtA structures cAn simplify problem-
solving in softwAre development.

REFERENCES :-
1.study mAteriAls
2. notes
3.documentAtion
4. websites used- w3 schools for bAsic
concepts…

You might also like