[algogeeks] Re: Stortest Subtext Problem

2008-02-14 Thread hc busy
It seems that the algorithms are O(Nk) where N is size of document and k is number of keywords needed. So this means if you are looking for a N/2 words in a document of length N, the worst case will actually be O(N^2). Not something that you'll get from a google query, but still possible for

[algogeeks] Re: a non-recursive algorithm that prints all the nodes of a binary tree in O(n)

2008-02-12 Thread hc busy
I agree, this seems like freshman algo homework, ask TA for a hint. The algorithm I described previously works fine. and it's probly in one of the books anyways... U need something like a Potential function, and do some monkeying around with it and it all works out. On Feb 11, 10:04 pm, Sunny

[algogeeks] Re: Printing Binary tree data level by level without using BFS

2008-02-11 Thread hc busy
, 5:12 pm, hc busy [EMAIL PROTECTED] wrote: U, well, there is an 2^(1+lg(D))-1 time algorithm that uses constant memory for a tree of size D. So, that's O(D). Just do df-traversal for all levels of the tree outputting only the nodes at current level. On Jan 31, 2:18 am, dor [EMAIL

[algogeeks] Re: Printing Binary tree data level by level without using BFS

2008-02-01 Thread hc busy
U, well, there is an 2^(1+lg(D))-1 time algorithm that uses constant memory for a tree of size D. So, that's O(D). Just do df-traversal for all levels of the tree outputting only the nodes at current level. On Jan 31, 2:18 am, dor [EMAIL PROTECTED] wrote: O(n) extra memory will suffice,

[algogeeks] Re: Printing Binary tree data level by level without using BFS

2008-02-01 Thread hc busy
U, well, there is an 2^(1+lg(D))-1 time algorithm that uses constant memory for a tree of size D. So, that's O(D). Just do df-traversal for all levels of the tree outputting only the nodes at current level. On Jan 31, 2:18 am, dor [EMAIL PROTECTED] wrote: O(n) extra memory will suffice,

[algogeeks] Re: can you solve these questions!!!

2008-01-29 Thread hc busy
did u find this number ? k bye On Jan 26, 2008 3:32 AM, hc busy [EMAIL PROTECTED] wrote: #2 is weird, start by observing that if you've seen n/2+2 items then you're done. You want n/2+1 equal numbers. So there needs to be a number that is repeated once after seeing n/2+2 numbers

[algogeeks] Re: can you solve these questions!!!

2008-01-29 Thread hc busy
did u find this number ? k bye On Jan 26, 2008 3:32 AM, hc busy [EMAIL PROTECTED] wrote: #2 is weird, start by observing that if you've seen n/2+2 items then you're done. You want n/2+1 equal numbers. So there needs to be a number that is repeated once after seeing n/2+2 numbers

[algogeeks] Re: Finding the subtree with the largest weight

2008-01-29 Thread hc busy
return max( 0/*zero*/, (max(R,L,R+L)+root.value), R, L, root.value); On Jan 29, 1:40 am, Nima Aghdaie [EMAIL PROTECTED] wrote: int maxw(node root) { if(root == null) return (0); int L = maxw(root.lchild); int R = maxw(root.rchild); return max(

[algogeeks] Re: Finding the subtree with the largest weight

2008-01-29 Thread hc busy
return max( 0/*zero*/, (max(R,L,R+L)+root.value), R, L, root.value); On Jan 29, 1:40 am, Nima Aghdaie [EMAIL PROTECTED] wrote: int maxw(node root) { if(root == null) return (0); int L = maxw(root.lchild); int R = maxw(root.rchild); return max(

[algogeeks] Re: can you solve these questions!!!

2008-01-25 Thread hc busy
#2 is weird, start by observing that if you've seen n/2+2 items then you're done. You want n/2+1 equal numbers. So there needs to be a number that is repeated once after seeing n/2+2 numbers for this to be possible(and the rest must all be the same), now divide and conquer. For all possible

[algogeeks] Re: compute (multimonial type) probability expression

2008-01-25 Thread hc busy
If you take k balls out of a bunch of N balls, the probability of having selected k balls is always one(1.0). It takes no calculation, because after you sum that expression up, it add up to one by definition/law of probability. On Jan 23, 5:12 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I

[algogeeks] Re: can you solve these questions!!!

2008-01-25 Thread hc busy
#2 is weird, start by observing that if you've seen n/2+2 items then you're done. You want n/2+1 equal numbers. So there needs to be a number that is repeated once after seeing n/2+2 numbers for this to be possible(and the rest must all be the same), now divide and conquer. For all possible

[algogeeks] Re: Expectation-Maximization algorithm

2008-01-17 Thread hc busy
Expectation Maximisation. I think the typical classroom example is fitting k normal curves to data, and in that case, the best-fitting k normal kurves will give the best Expectation. But the one thing that people don't like about this is that it's not guaranteed to find all of them. They're

[algogeeks] Re: arc length

2008-01-07 Thread hc busy
Now it's harder. For arbitrary image, you'll have to identify where the circle is. But Jame's answer seems fine if the ONLY thing on the picture is the circle and the two segments. just look for the left most intersection and the right most intersection then follow the line. On Jan 4, 5:15 pm,

[algogeeks] Re: Dynamic Programming Algorithm for swim relay team

2008-01-07 Thread hc busy
manner using dynammic programming. HTH, Satish On Jan 4, 1:45 am, hc busy [EMAIL PROTECTED] wrote: At risk of stating the incredibly obvious, or giving away answer to a fun interview question. The naive but correct algorithm that gives the solution will have tried every combination M

[algogeeks] Re: arc length

2008-01-04 Thread hc busy
If you can scan pixels, why not just count # of pixels in the arc and multiply by size of each pixel? finding line intersection seems like a hard thing especially on a scanned image like this one. oh wait minute, it's an image... do you mean you want to find the ratio of arc to circumference?

[algogeeks] Re: Dynamic Programming Algorithm for swim relay team

2008-01-03 Thread hc busy
At risk of stating the incredibly obvious, or giving away answer to a fun interview question. The naive but correct algorithm that gives the solution will have tried every combination M of K swimmers in M events. which will give you K!/(K-M)! arrangements, and the algorithm would then compare