[algogeeks] Find The Kth min in a binary search tree

2010-07-25 Thread Debanjan Ghosh
int FindKthSmallest(TreePointer ptr){ int count=0; if(ptr){ FindKthSmallest(ptr->leftchild); count++; FindKthSmallest(ptr->rightchild); } return count; } -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to a

[algogeeks] Re: use putchar to print out an unsigned long in decimal

2009-10-15 Thread Debanjan
On Oct 15, 10:45 am, umesh kewat wrote: > Hi, > Here is the code for problem... > > void print(unsigned long int n) > { >     if(n<10) > >         putchar(n+48); >     else >         { >         print(n/10); >         putchar(n%10); >         } > > } > > int main() > { >     unsigned long int n;

[algogeeks] Re: ROTATE

2009-10-15 Thread Debanjan
On Oct 12, 5:02 pm, ankur aggarwal wrote: > *You are given a integer and you want to rotate the bits of the number by a > value x. Consider the right rotation by x means the least significant x bits > should go out from left and take the position of most significant x bits.* Might be a late resp

[algogeeks] Re: use putchar to print out an unsigned long in decimal

2009-10-15 Thread Debanjan
On Oct 15, 9:03 am, ankur aggarwal wrote: > 1.      Given only putchar (no sprintf, itoa, etc.) write a routine putlong > that prints out an unsigned long in decimal. Well,this is rather very easy : void putlong(unsigned long long num) { if(num > 9) putlong(num/10); putchar(num%1

[algogeeks] Re: DS question

2009-10-13 Thread Debanjan
On Sep 8, 10:47 am, yash wrote: > wap a program in efficient manner to remove all occurrence of > duplicate character in the word and all occurrence of duplicate word > in the file. > > i break the problem in two section( this is my approach it may be > better one ) > > wap to remove all duplicat

[algogeeks] Re: DS question

2009-10-13 Thread Debanjan
On Sep 8, 10:47 am, yash wrote: > wap a program in efficient manner to remove all occurrence of > duplicate character in the word and all occurrence of duplicate word > in the file. > > i break the problem in two section( this is my approach it may be > better one ) > > wap to remove all duplicat

[algogeeks] Re: DS question

2009-10-13 Thread Debanjan
On Oct 13, 12:05 pm, Raghavendra Sharma wrote: > For the first problem. > > All occurrence of a duplicate character in a word. > > void RemoveDuplicates(char *word) { >   int count[256] = {0, 0}; >   char *p = word; > >   while ( p ) { This would be while(*p) { >     count[(int)(*p)] = 1; >    

[algogeeks] Re: DS question

2009-10-13 Thread Debanjan
OOPS sorry the code is not correct. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com To unsubscribe from this group, send email

[algogeeks] Re: 100!

2009-10-11 Thread Debanjan
On Oct 11, 10:29 am, Anil C R wrote: > Project Euler!! I remember I cheated on this problem :P At first I used my SPOJ FCTRL2 solution to get the factorial of 100 then I simply add up those digits :D Most problems of Project Euler can be brute forced ! --~--~-~--~~~--

[algogeeks] Re: Interesting array multiplication problem

2009-10-10 Thread Debanjan
On Oct 10, 9:12 pm, Ramaswamy R wrote: > Two passes. Initialize the result array with all 1's. > Pass 1: Maintain the product until i-1 when processing element at i. The > product would be 1 for the 0th element. For every i'th element of the result > array, multiply it with the product (till th

[algogeeks] Re: sum of subsequence.

2009-10-09 Thread Debanjan
On Oct 9, 8:56 am, ankur aggarwal wrote: > 2. Given an array all of whose elements are positive numbers, find the > maximum sum of a subsequence with the constraint that no 2 numbers in the > sequence should be adjacent in the array. > >  i) 3 2 7 10 should return 13 (sum of 3 and 10) > > ii) 3