Professional Documents
Culture Documents
Thota Chakradhar - DS
Thota Chakradhar - DS
Thota Chakradhar - DS
2020CSB094
struct node
int data;
struct node*link;
};
ptr‐>data=data;
ptr‐>link=NULL;
if(head==NULL)
head=ptr;
ptr==NULL;
return head;
else{
struct node*tmp=head;
while(tmp‐>link!=NULL)
tmp=tmp‐>link;
tmp‐>link=ptr;
ptr,tmp=NULL;
return head;
struct node*ptr=head;
int pos=1;
while(ptr!=NULL)
if(ptr‐>data==ele)
return pos;
else
ptr=ptr‐>link;
pos++;
int main()
struct node*head=NULL;
int x,data;
while(x!=0){
scanf("%d",&x);
if(x!=0){
scanf("%d",&data);
head=add_at_end(head,data);
//PRINTING LIST
struct node*ptr=head;
while(ptr!=NULL)
printf("%d\t",ptr‐>data);
ptr=ptr‐>link;
}
ptr=NULL;
//SEARCHING ELEMENT
int e,pos;
scanf("%d",&e);
pos= search_for_ele(head,e);
return 0;