varun.friendly
BAN USERi have a good and easy code.
char *one[]={"","one","two",.......,"nineteen");
char *ten[]=("","","twenty","thirty"......"ninty");
void pw(long n,char *s);
int main()
{
long n;
char *s;
if(n>=0)
{
pw(n/10000000,"crore");
pw((n/1000000)%100,"lakh");
pw((n/1000)%100,"thosand");
pw((n/100)%10,"hundred");
pw(n%100,"");
}
return;
}
void pw(long n,char *s)
{
(n>19)?printf("%s %s",ten[n/10],one[n%10]):printf("%s",one[n]);
if(n)
printf("%s",s);
}
give ur feedback on this code.
b_level(root,k)
{
if(k==0)
printf(root->value)
else
{
b_level(root->left,k-1);
k--;
b_level(root->right,k);
}
}
int main()
{
for(k=0,k<h;k++) //h is hgt of tree
{
b_level(root,k);
}
return;
}
this is the code given in NI paper on 14 sep in NITK, surathkal
they asked to find what code is doing.. it is printing all nodes at kth level. you can trace.
@Kishore i think for 5 it should be bitarray[5-min]=1 since ur taking the array of size max-min.
- varun.friendly March 03, 2011Correct me if I am wrong.
@Anonymous can u explain abt order statistics