Re: [algogeeks] Re: Binary tree to BST

2011-11-06 Thread Anika Jain
@mohit: your algo will add assurance that the tree is balanced.. otherwise ankit's approach is sufficient. On Sat, Nov 5, 2011 at 8:49 PM, mohit verma mohit89m...@gmail.com wrote: another way is : convert binary tree to link list , sort the list and using divide and conquer approach create

[algogeeks] Problem of calculating large binomial coefficients which large base so lucas theorem cant be applied

2011-11-06 Thread pankajsingh
i want to calculate values like (100 C 1) %17,what would be better algorithm for it,i think lucas theorem cant be used in this case.want some efficent algorithm,actually i want to calculate mC1,mC2mC1000 %17,such that may is about 10^6 -- You received this message

Re: [algogeeks] Re: Median of 2D matrix

2011-11-06 Thread mohit verma
@Gene As i said in my earlier post right to left diagonal partitions the martix into 2 equal number of elements. So now the median must be in this diagonal. Now our focus is on finding median of this diagonal only. I think this works fine. Can u give some test case for which it fails? On Sun, Nov

Re: [algogeeks] Re: Median of 2D matrix

2011-11-06 Thread Robert Badita
It's the wrong diagonal and that algo still holds until another example. btw I think if the median of the sorted matrix is the median of the second diagonal then you have found a stable algorithm to find the median of any array by sorting rows and columns in O(2 sqrt N * sqrt N * log sqrt N) =

[algogeeks] Re: Problem of calculating large binomial coefficients which large base so lucas theorem cant be applied

2011-11-06 Thread Dave
@Pankajsingh: See the recent thread Modular arithmetic + Combinatorics in this newsgroup. Dave On Nov 6, 12:49 am, pankajsingh psingh...@gmail.com wrote: i want to calculate values like (100 C 1) %17,what would be better algorithm for it,i think lucas theorem cant be used in

[algogeeks] Re: Median of 2D matrix

2011-11-06 Thread Dave
@Mohit: Here is a counterexample: 10 1152 53 54 20 21 112 113 114 30 31 122 123 124 40 41 132 133 134 50 91 142 143 144 The median is 91, and it is not on the anti-diagonal. Dave On Nov 6, 3:11 am,

Re: [algogeeks] Re: heap memory

2011-11-06 Thread himanshu kansal
@Gene: since the article itself says that if the memory is allocated through malloc, it will make some (less) sbrk calls to the system to increase the allocated memory to the program. then how can a wrapper function will do the malloc internally will call the sbrk function and will increase

[algogeeks] program to convert roman to integer.........

2011-11-06 Thread rahul sharma
i.p: v o/p 5 i/p ix o/p:9 -- 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 to algogeeks+unsubscr...@googlegroups.com. For more options,

Re: [algogeeks] Re: Problem of calculating large binomial coefficients which large base so lucas theorem cant be applied

2011-11-06 Thread pankajsingh
Thanks Dave, but i want some more efficient in my case, something like O(k) to calculate all mC1 mC2...mCk, i already had a worst time O(k^2), i.e for (long long int i1=1;i1=k;i1++) { while((result*(m-i1+1))%i1) { result=result+17; } result=(result*( m-i1+1)); result /= i1;

Re: [algogeeks] program to convert roman to integer.........

2011-11-06 Thread Vandana Bachani
/Convert roman to decimal #includestdio.h int convert(char *s, int len) { int i = 0, d = 0, prev = 0; for(;i len; i++) { switch(*(s+i)) { case 'i': d += 1; break; case 'v': if(i!=0 *(s+prev) == 'i') { d = d + 5 - 2; } else