ds[1]
ds[1]
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.
➢ Arrays
➢ Linked Lis
➢ Stack
➢ Queue
#include <stdlib.h>
#include <string.h>
struct Contact {
char name[50];
char phone[15];
};
strcpy(newContact->name, name);
strcpy(newContact->phone, phone);
newContact->prev = NULL;
newContact->next = NULL;
return newContact;
}
if (head == NULL) {
head = newContact;
} else {
temp = temp->next;
temp->next = newContact;
newContact->prev = temp;
void displayContacts() {
if (head == NULL) {
return;
}
printf("\nPhone Directory:\n");
temp = temp->next;
if (head == NULL) {
return;
if (strcmp(temp->name, name) == 0) {
return;
}
temp = temp->next;
if (head == NULL) {
return;
temp = temp->next;
if (temp == NULL) {
return;
}
// If the contact to delete is the head
if (temp == head) {
head = head->next;
else {
if (temp->next != NULL) {
temp->next->prev = temp->prev;
if (temp->prev != NULL) {
temp->prev->next = temp->next;
free(temp);
int main() {
int choice;
printf("5. Exit\n");
scanf("%d", &choice);
switch (choice) {
case 1:
break;
case 2:
displayContacts();
break;
case 3:
name[strcspn(name, "\n")] = 0;
searchContact(name);
break;
case 4:
name[strcspn(name, "\n")] = 0;
deleteContact(name);
break;
case 5:
printf("Exiting Phone Directory. Goodbye!\n");
break;
default:
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…