Professional Documents
Culture Documents
German History
German History
-27
//Code for binary search tree.
#include <stdio.h>
int main()
int n, size, i;
int list[25];
scanf("%d", &size);
printf("Enter elements\n");
scanf("%d",&list[i]);
sort(list, size);
printf("\n");
scanf("%d", &n);
bin_search(list,0,size,n);
return 0;
int temp, i, j;
for (i = 0;i<size;i++)
for (j=i;j<size;j++)
if (list[i]>list[j])
temp = list[i];
list[i] = list[j];
list[j] = temp;
int mid;
if (l>m)
return;
mid = (l+m) / 2;
if (list[mid]==n)
printf("Element found\n");
else if (list[mid]>n)
bin_search(list,l,mid-1,n);
}
else if (list[mid]<n)
bin_search(list,mid+1,m,n); }
}
//Code for multi processing environment
#include<stdio.h>
#include<stdlib.h>
int num, d;
} nodetype ;
void display(nodetype*);
int main(){
nodetype *l=NULL;
scanf("%d", &time);
scanf("%d", &n);
int i=0;
while(i<n){
scanf("%d", &x);
insert(&l, x , i+1);
i++;
}
task(&l, time, n);
return 0;
nodetype *p=NULL;
p=(nodetype*)malloc(sizeof(nodetype));
if(p!=NULL){
p->num=n;
p->d=d;
if(*l==NULL){
*l = p;
(*l)->next = p;
return;
p->next=(*l)->next;
(*l)->next=p;
(*l)=p;
if(q->next==q)
free(q);
*p=NULL;
return;
r=q->next;
q->next=r->next;
free(r);
*p=q;
nodetype *p = *l;
while(p!=NULL)
nodetype *f=p->next;
f->d=f->d-time;
if((f->d)<=0)
if(f==*l)
*l=p;
delete(&p);
else
p=p->next;
display((*l)->next);
nodetype *temp;
temp=l;
if(l==NULL)
else
{
printf("%d\t",l->d);
temp=temp->next;
while(temp!=l)
printf("%d\t",temp->d);
temp=temp->next;
printf("\n");