Skip to content
This repository was archived by the owner on Sep 7, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions data-structures/Circular_Linked_List.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#include <iostream>
#include <conio.h>

using namespace std;

int main()
{

struct node{
int info;
node *next;
}*ptr,*head,*start;

int c=1,data;

ptr=new node;
ptr->next=NULL;

start=head=ptr;

while(c<3 && c>0){
cout<<"1.Insert\n2.Link List\n";
cin>>c;

switch(c){
case 1:
cout<<"Enter Data\n";
cin>>data;

ptr=new node;
ptr->next=start;
ptr->info=data;

head->next=ptr;
head=ptr;

break;

case 2:
ptr=start->next;

while(ptr!=start && ptr!=NULL){
cout<<ptr->info<<"->";
ptr=ptr->next;
}
cout<<"\n";
break;

default:
cout<<"Wrong Choice\nExiting...\n";
}

}

getch();
return 0;
}
93 changes: 93 additions & 0 deletions data-structures/Doubly_Linked_List.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#include <iostream>
#include <conio.h>

using namespace std;
int main()
{
struct node{
int info;
node *left,*right;
}*ptr,*start,*last,*save;

int c=1,i=0,data,item;
start=last=NULL;

while(c<4 && c>0){
cout<<"1.Insert\n2.Deletion\n3.Link List\n";
cin>>c;

switch(c){
case 1:
cout<<"Enter Data\n";
cin>>data;

ptr=new node;
ptr->info=data;
ptr->left=last;
ptr->right=NULL;

if(start==NULL){
start=last=ptr;
}

else{
last->right=ptr;
last=ptr;
}
break;

case 2:
if(start==NULL){
cout<<"Underflow\n";
}

else{
cout<<"Enter Item to be Deleted\n";
cin>>item;
ptr=start;

while(ptr!=NULL){
if(ptr->info==item){
i++;
if(ptr==start){
start->left=NULL;
start=start->right;
}

else{
ptr->left->right=ptr->right;
ptr->right->left=ptr->left;
}
delete ptr;
cout<<"Item Deleted\n";
}
ptr=ptr->right;
}

if(i==0){
cout<<"Item Does not exist\n";
}
i=0;
}
break;

case 3:

ptr=start;

while(ptr!=NULL){
cout<<ptr->info<<"->";
ptr=ptr->right;
}
cout<<"\n";
break;

default:
cout<<"Wrong Choice\nExiting...\n";
}

}

getch();
return 0;
}