ivikas007
BAN USER#include<stdio.h>
#include<stdlib.h>
int greater(int k,int l)
{
int temp=0;
int templ;
int tempk;
int kl;
int lk;
if(k==-100000)
return(0);
if(l==-100000)
return(1);
temp=10;
templ=l;
tempk=k;
while(templ/10!=0)
{
templ=templ%10;
temp=temp*10;
}
kl=k*temp+l;
temp=10;
while(tempk/10!=0)
{
tempk=tempk%10;
temp=temp*10;
}
lk=l*temp+k;
if(kl>lk)
return(1);
else
return(0);
}
Modified_Merge(int A[],int p,int r,int q)
{
int *l1;
int *l2;
int n1;
int n2;
int i;
int j;
int k;
n1=r-p+1;
n2=q-r;
l1=(int *)malloc((n1+1)*sizeof(int));
l2=(int *)malloc((n2+1)*sizeof(int));
for(i=0;i<n1;i++)
l1[i]=A[p+i];
for(j=0;j<n2;j++)
l2[j]=A[r+1+j];
l1[n1]=-100000;
l2[n2]=-100000;
i=0;
j=0;
k=p;
while(i!=n1||j!=n2)
{
if(greater(l1[i],l2[j]))
{
A[k]=l1[i];
i++;
k++;
}
else
{
A[k]=l2[j];
j++;
k++;
}
}
}
Modified_Merge_Sort(int A[],int p,int q)
{
int r;
if(p<q)
{
// printf("yessss%d,%d\n",p,q);
r=(p+q)/2;
Modified_Merge_Sort(A,p,r);
Modified_Merge_Sort(A,r+1,q);
Modified_Merge(A,p,r,q);
}
else
return;
}
int main()
{
int n;
int *A;
int i=0;
printf("Inter the number of Integer:\n");
scanf("%d",&n);
A=(int *)malloc(n*sizeof(int));
while(i<n)
{
scanf("%d",A+i);
i++;
}
Modified_Merge_Sort(A,0,n-1);
for(i=0;i<n;i++)
printf("%d,",A[i]);
}
int Diameter_BST_Without_HeightFunction_Return_Diameter(node *temp,int *Height)
{
int lh;
int rh;
int h;
int TempDiam;
int LeftDiam;
int RightDiam;
if(temp==NULL)
{
*Height=0;
return(0);
}
LeftDiam=Diameter_BST_Without_HeightFunction_Return_Diameter(temp->left,&lh);
RightDiam=Diameter_BST_Without_HeightFunction_Return_Diameter(temp->right,&rh);
// printf("key==%d,%d,%d\n",temp->key,*Diameter,TempDiam);
if(lh>rh)
*Height=lh+1;
else
*Height=rh+1;
TempDiam=rh+lh;
if(TempDiam<LeftDiam)
{
TempDiam=LeftDiam;
}
if(TempDiam<RightDiam)
{
TempDiam=RightDiam;
}
return(TempDiam);
}
- ivikas007 October 03, 2012Data Structure : stack s;
step1 :s<-push(DAMP)
step2: w<-pop(s)
if(w!=LIKE)
go to step3
else
return
step3: push all word which are in dictionary and can be get after changing at single place of w into stack if it is not present and it wasn't pushed earlier.
go to step 2
Data Structure : stack s;
step1 :s<-push(DAMP)
step2: w<-pop(s)
if(w!=LIKE)
go to step3
else
return
step3: push all word which are in dictionary and can be get after changing at single place of w into stack if it is not present and it wasn't pushed earlier.
go to step 2
1:First Take the transpose of the matrix.
2:Reverse Each Row of the matrix.
Code:
}
- ivikas007 October 24, 2012