Skip to content
Open
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
36 changes: 33 additions & 3 deletions Link_List/link_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void DELETE(struct Node **h){
}

void a_shorting(struct Node **h){
struct Node *temp,*c,*i,*j;
struct Node *temp,*i,*j;
int temp_value;
/* int n=0,p,q;
temp = *h;
Expand Down Expand Up @@ -170,6 +170,23 @@ void Display(struct Node**h){
}
}
}
int search(int value, struct Node**h)
{
struct Node *p;
p = *h;
while(p != NULL)
{
if(p->value == value)
{
return 1;
}
else
{
p = p->ptr;
}
}
return 0;
}


int main(){
Expand All @@ -184,11 +201,12 @@ int main(){
printf("6 for delete Link Node\n");
printf("7 for sorting Link list in ascending order \n");
printf("8 for display the list\n");
printf("9 for Exit\n");
printf("9 for Search\n");
printf("10 for Exit\n");
printf("Enter which type of the operation you want to apply: ");
scanf("%d",&n);

while(n !=9){
while(n !=10){

switch(n){
case 1:
Expand Down Expand Up @@ -223,6 +241,18 @@ int main(){
Display(&HEAD);
printf("\n");
break;
case 9:
printf("Enter a value to search : ");
scanf("%d", &value);
if(search(value, &HEAD) == 1)
{
printf("%d found in the list.\n\n", value);
}
else
{
printf("%d not found in the list.\n\n", value);
}
break;
default:
printf("Enter specific value:\n");
}
Expand Down