[algogeeks] Re: random number...

2009-09-08 Thread Karthik Singaram Lakshmanan
Not that I am trying to prove a point...but just trying to clarify what I said... A uniform random number generator, say rand_5() produces a value 2 with probability 1/5 it can produce a sequence of two 2s with probability (1/5)^2 it can produce a sequence of three 2s with probability (1/5)^3

[algogeeks] Re: Missing numbers

2009-08-03 Thread Karthik Singaram Lakshmanan
well..will this work? x + y = SUM(1:N+2) - SUM(array) = a x^2 + y^2 = SUM(1^2:(N+2)^2) - SUM(array.^2) = b so (a^2 - b) = 2xy so xy = (a^2-b)/2 = k (say) now, x + (k/x) = a x^2 + k = ax (x, y) = (a +/- sqrt(a^2-4k))/2 I may not have written the equations correctly (need coffee !!!) but you

[algogeeks] Re: Pyramid algorithm?

2009-01-19 Thread Karthik Singaram Lakshmanan
Well. I would suggest the following. If n is the number of stackable objects, You could compute the largest value of x such that x*(x+1)/2 = n Then you can arrange the objects as O OO OOO O..O (x objects) Now the remaining can be placed in the last row. Without violating the constraints this

[algogeeks] Re: Lucky numbers

2009-01-05 Thread Karthik Singaram Lakshmanan
Its not clear that just a primality test would close the deal...The sequence 1,3,7,13...does not have 5 which is prime. If you consider a number 'n' for it to be removed in round 2 (n%2)==0 For it to be removed in round 3 (n-floor(n/2))%3==0 (The floor of n/2 to accommodate all the numbers thrown

[algogeeks] Re: Multi-level Markov chains

2008-10-28 Thread Karthik Singaram Lakshmanan
I am not an expert with markov chains, but I hope this pointer helps. http://rubyquiz.com/quiz74.html --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

[algogeeks] Re: Seeking an answer for a question from a test in algo

2008-09-17 Thread Karthik Singaram Lakshmanan
Yes...|E| has to be greater than or equal to |V|, otherwise we know that there cannot be a root node. Then do a simple BFS, since O(|E|)O(|V|), we can technically call it O(|E|) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the

[algogeeks] Re: recurrence relation

2008-09-14 Thread Karthik Singaram Lakshmanan
Isn't n-2^logn = 0? since 2^logn = n if you are talking about log base 2 --~--~-~--~~~---~--~~ 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

[algogeeks] Re: generating a random number having uniform distribution using random coin flips

2008-04-14 Thread Karthik Singaram Lakshmanan
RANDOM(0,1)*(b-a)+a On Mon, Apr 14, 2008 at 10:15 AM, deeepanshu shukla [EMAIL PROTECTED] wrote: hello everybody ... can anyone help me solving this Describe an implementation of the procedure RANDOM(a, b) that only makes calls to RANDOM(0, 1). What is the expected running

[algogeeks] Re: Plannar graph

2008-04-03 Thread Karthik Singaram Lakshmanan
Correct that to : There exists at least one vertex of degree at most 5 --~--~-~--~~~---~--~~ 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

[algogeeks] Re: Plannar graph

2008-03-25 Thread Karthik Singaram Lakshmanan
I agree with you..I was replying to kunzmilan: Planarity can be defined differently. Graph K(4) Can be drawn without crossing arcs. Newertheless, as tetrahedron, it is not planar. To both forms, different distance matrices belong. --~--~-~--~~~---~--~~ You

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

2008-02-11 Thread Karthik Singaram Lakshmanan
keep track of the last node you visited... if you are coming from the left child, go to the right child... if you are coming from the right child, go to the parent... thats the brief idea... --~--~-~--~~~---~--~~ You received this message because you are subscribed

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

2008-02-11 Thread Karthik Singaram Lakshmanan
assume parent pointers...then you can --~--~-~--~~~---~--~~ 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