[algogeeks] Re: Implement a queue in which push_rear(), pop_front() and get_min() are all constant time operations.

2011-01-02 Thread juver++
Simulate queue using two stacks. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more

Re: [algogeeks] puzzle

2011-01-02 Thread jai gupta
@swayambhoo: ofcourse a cubical room must me symmetrical at allcorners, Hence, neway it will reach in min_dis=sqrt((4+3)^2+5^2)=8.6 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

Re: [algogeeks] Find a specific number in a special matrix.

2011-01-02 Thread jai gupta
For n x m take first element of all the rows and insert in a min heap. Now take the smallest element and and if we have a track of from which row it belongs, we can take an element out of that row and insert in the heap. this will be done n x m times. Hence we have a time complexity of O(nmlog(m))

[algogeeks] Re: Float Comparison

2011-01-02 Thread juver++
a == b == a b - EPS a = b == a b + EPS all other relations are straighforward. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to

Re: [algogeeks] Plz Explain The Output.

2011-01-02 Thread juver++
char type is signed by default, so it represents value 255 as -1. Code outputs first byte as unsigned int value, where -1 == 4294967295. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

Re: [algogeeks] Re: Float Comparison

2011-01-02 Thread sanchit mittal
i was doin a check on which one of the two floats is greater using sign but was unable to do soi m actually solving this prob: http://www.codechef.com/JAN11/problems/FLUSHOT/ http://www.codechef.com/JAN11/problems/FLUSHOT/i hav code wid me shud i post it here? On Sun, Jan 2, 2011 at 9:13

Re: [algogeeks] Re: Float Comparison

2011-01-02 Thread sanchit mittal
i dont know how shud i modify my code using epsilon shall i mail it to someone or straightaway post it here .? On Sun, Jan 2, 2011 at 9:58 PM, sanchit mittal sm14it...@gmail.com wrote: i was doin a check on which one of the two floats is greater using sign but was unable to do soi m

Re: [algogeeks] Re: Float Comparison

2011-01-02 Thread juver++
There is no need in epsilon comparison when you need to compare it with or operators. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send

Re: [algogeeks] Re: Float Comparison

2011-01-02 Thread sanchit mittal
#includestdio.h #includeconio.h int main() { int t,D,N,i; float T,*x,*y,*z,maxNo,minNo; scanf(%d,t); while(t--) { scanf(%d %f,N,T); x=(float*)malloc(sizeof(float)*(N+1)); y=(float*)malloc(sizeof(float)*(N+1));

Re: [algogeeks] Re: Float Comparison

2011-01-02 Thread sanchit mittal
oups gt my mistake.btw hnx for replying On Sun, Jan 2, 2011 at 10:10 PM, juver++ avpostni...@gmail.com wrote: There is no need in epsilon comparison when you need to compare it with or operators. -- You received this message because you are subscribed to the Google Groups Algorithm

[algogeeks] Enigma - Online Puzzle championship

2011-01-02 Thread Manjunath Manohar
Hi Enigma - Online puzzle championship organised by Kurukshetra, international tech fest of anna university under the patronage of UNESCO. So what u guys waiting for, exciting prizes are awaiting you. www.enigma.kurukshetra.org.in Regards, Enigma Team +91 9940014458 -- You received this

[algogeeks] codechef jan challenge

2011-01-02 Thread sanchit mittal
http://www.codechef.com/JAN11/problems/FLUSHOT/ *m getting wrong answer* *if there is any problem wid my algorythm do let me know* #includestdio.h int main() { int t,D,N,j,i; float T,*x,*y,*z,maxNo,minNo; scanf(%d,t); while(t--) { scanf(%d %f,N,T);

[algogeeks] Re: probability

2011-01-02 Thread Dave
@Salil: Just to make sure we are on the same page, A hits with 100% probability, B hits with 50% probability, and C hits with 33% probability. C shoots first, then B, then A. Then the shooting continues among the survivors in that order until only one is standing. If all three are alive and it is

Re: [algogeeks] codechef jan challenge

2011-01-02 Thread radha krishnan
Wow: Its a Running Contest :) On Sun, Jan 2, 2011 at 11:07 PM, sanchit mittal sm14it...@gmail.com wrote: http://www.codechef.com/JAN11/problems/FLUSHOT/ m getting wrong answer if there is any problem wid my algorythm do let me know #includestdio.h int main() {     int t,D,N,j,i;     

Re: [algogeeks] Re: Float Comparison

2011-01-02 Thread aniket chatterjee
This link may be helpful: http://www.cygnus-software.com/papers/comparingfloats/Comparing%20floating%20point%20numbers.htm -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To

Re: [algogeeks] Re: probability

2011-01-02 Thread Salil Joshi
@Dave 1. In the end only 1 will survive (after max of 2 rounds). i.e. P(A survives in end) + P(B survives in end) + P(C survives in end) = 1 2. Now, by shooting in air C increases his probability by your argument, which is not good for A. Thus, P(A shooting at C) should NOT be 0 if A is

[algogeeks] Re: codechef jan challenge

2011-01-02 Thread juver++
Solve it by yourslef. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options,

Re: [algogeeks] Re: Implement a queue in which push_rear(), pop_front() and get_min() are all constant time operations.

2011-01-02 Thread Anuj Kumar
@juver++ how will implwment find_min() function? On Sun, Jan 2, 2011 at 2:33 PM, juver++ avpostni...@gmail.com wrote: Simulate queue using two stacks. -- 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: probability

2011-01-02 Thread Dave
@Salil: If C shoots at A instead of into the air, he increases the odds that he will be shot by B, because if C hits A then B will shoot at C instead of A. On the other hand, if C shoots at B instead of into the air, he increases the odds that he will be shot by A. Thus, shooting at either A or

Re: [algogeeks] Re: Implement a queue in which push_rear(), pop_front() and get_min() are all constant time operations.

2011-01-02 Thread yq Zhang
keep min for stack is easy. just use another stack to keep the min for each top. Sent from Nexus one On Jan 2, 2011 11:43 AM, Anuj Kumar anuj.bhambh...@gmail.com wrote: @juver++ how will implwment find_min() function? On Sun, Jan 2, 2011 at 2:33 PM, juver++ avpostni...@gmail.com wrote:

Re: [algogeeks] Re: Longest Palindrome

2011-01-02 Thread aniket chatterjee
@Anand:I went through the link posted in your blog.But I found the method little bit hard to understand. @Aviral:Please elaborate the approach or give some link as in your blog I didn't find the solution. It will be very helpful.Thanks in advance. -- You received this message because you are

Re: [algogeeks] Re: Interview question amazon

2011-01-02 Thread rahul patil
On Sun, Jan 2, 2011 at 8:30 PM, Akash Agrawal akash.agrawa...@gmail.comwrote: I have written a kinda messed-up code for the same. Which is basically a bottom-up approach. Please find the same as attached. Some boundary conditions might be missed and code can be written in a more decorated,

[algogeeks] Re: Longest increasing subsequence

2011-01-02 Thread Prims
Hello Anand I am getting the error Blog not found . Could you please provide me the correct link. -Prims On Dec 31 2010, 1:44 pm, Anand anandut2...@gmail.com wrote: Longest increasing subsequence using segment tree with O(nlogn)

Re: [algogeeks] Re: probability

2011-01-02 Thread Salil Joshi
@Dave In point # 1, I had mentioned that P(A survives) + P(B survives) + P(C survives) = 1 as the dual will be carried out till only 1 man is left. Do you agree on this? By your calculations, P(A survives) = 0.17 * 1 + 0.5 = 0.67 P(C survives) = 0.4962 They add to more than 1. Please let me know