//concatination of two single linked list
#include
#include
#include
#include
struct linkedlist
{
int info;
struct linkedlist *next;
};
typedef struct linkedlist NODE;

NODE * create(NODE *);
void display(NODE *);
NODE * concatinate(NODE *,NODE *);
NODE *head;
NODE * node1,* node2;
NODE start;
void main()
{
clrscr();
node1=(NODE *)malloc(sizeof(NODE));
printf("\n create first linked list \n");
node1=create(node1);
printf("\n first linked list is \n");
display(node1);
printf("\n create second linked list \n");
node2=(NODE*)malloc(sizeof(NODE));
node2=create(node2);
printf("\n second linked list is \n");
display(node2);
node1=concatinate(node1,node2);
printf("\n after concatination list is \n");
display(node1);
getch();
}

NODE *create(NODE * list)
{
int a;
printf("\n enter a number to add (at end press -0)-->");
scanf("%d",&a);
if(a==-0)
{
list->info=a;
list->next=NULL;
return (list);
}
else
{
list->info= a;
list->next=(NODE *)malloc(sizeof(NODE));
create(list->next);
}
return(list);
}

void display (NODE *node)
{
printf("\n ROOT->");
while(node->next!=NULL)
{
printf("%d->",node->info);
node=node->next;
}
printf("NULL");
}

NODE *concatinate(NODE * list1, NODE * list2)
{
NODE *temp=list1;
while(list1->next->next!=NULL)
{
list1=list1->next;
}
if(list1->next->next==NULL)
{
list1->next=list2;
}
list1=temp;
return(list1);
}

//quick sorting of integers
#include
#include
void sort(int a[],int first,int last)
{
int temp,low,high,mid;
low=first;
high=last;
mid=a[(first+last)/2];
do
{
while(a[low] < mid)
low++;
while(a[high] > mid)
high--;
if(low <=high)
{
temp=a[low];
a[low]=a[high];
a[high]=temp;
low++;
high--;
}
}
while(low <= high);

if(first < high)
{
sort(a,first,high);
}
if(low < last)
{
sort( a,low,last);
}
}

void main()
{
int a[10],i,n;
printf("\n enter the size of the array -->");
scanf("%d",&n);
printf("\n enter array elements one by one \n");
for(i=0;i
#include
#include
#include
#include
struct linked_list
{
int info;
struct linked_list *next;
};
typedef struct linked_list NODE;


NODE * create (NODE *);
void display(NODE *);
int count(NODE *);
NODE *insert(NODE *,int);
NODE *search(NODE *,int);
NODE start;


NODE *create(NODE * node)
{

char ans ='y';
start.next=NULL;
node =&start;
while(ans=='y')
{
node->next=(NODE*)malloc(sizeof(NODE));
node=node->next;
printf("\n enter a number to add->");
scanf("%d",&node->info);
node->next=NULL;
printf("\n do you want to ad more node(y/n)");
scanf(" %c",&ans);
}
return(node);
}

void display (NODE *node)
{
node= &start;
node=node->next;

printf("\n ROOT->");
while(node!=NULL)
{
printf("%d->",node->info);
node=node->next;
}
printf("NULL");
}

int count(NODE *node)
{
node=&start;
int c=0;
while(node->next!=NULL)
{
c++;
node=node->next;
}
return (c);
}
NODE *insert(NODE *node,int key)
{
node=&start;
NODE *newnode,*n1;
NODE *temp=node;
if(node->info==key)
{
newnode=(NODE *)malloc(sizeof(NODE));
printf("\n enter a number to add->");
scanf("%d",&newnode->info);
newnode->next=node;
node=newnode;
return(node);
}
else
{
n1=search(node,key);
if(n1==NULL)
{
printf("\n searching node not found");
exit(0);
}

newnode=(NODE*)malloc(sizeof(NODE));
printf("\n enter a number to add->");
scanf("%d",&newnode->info);
newnode->next=n1->next;
n1->next=newnode;
return(temp);


}
}

NODE *search(NODE *node,int key)
{
node=&start;
while(node!=NULL)
{
if(node->info==key)
{
return(node);
}
node=node->next;
}
return(NULL);
}

void main()
{

NODE *head;
int key;
head=create(head);
printf("\n after creation linked list is--->\n");
display(head);
printf("\n total number of nodes=%d",count(head));
printf("\n enter a searching number where new node will be inserted-->");
scanf("%d",&key);
head=insert(head,key);
printf("\n after insertion list is=\n");
display(head);
getch();
}

CSS Menu Samples