@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
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
@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
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) =
@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
@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,
@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
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,
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;
/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
10 matches
Mail list logo