Re: [algogeeks] Find peak element in log(n)

2012-06-24 Thread adarsh kumar
ahh yes, as prakhar says, if the array is bitonic, my approach will work for O(log n). On Sun, Jun 24, 2012 at 1:57 AM, Prakhar Jain jprakha...@gmail.com wrote: I think it can't be done in O(log n) as per given problem constraints. It can be done in O(log n) if additional information that

Re: [algogeeks] Find peak element in log(n)

2012-06-24 Thread rajesh pandey
@Hassan According to the algorithm there is no peak for 2 ,3,1,7 ,8 ,10 ,12 . but there is one 3 . Regards Rajesh Pandey On Sun, Jun 24, 2012 at 1:57 AM, Prakhar Jain jprakha...@gmail.com wrote: I think it can't be done in O(log n) as per given problem constraints. It can be done in

Re: [algogeeks] Find peak element in log(n)

2012-06-24 Thread aditya gupta
@sourabh notice the definition of peak in the link given earlier. it says that peak element would not be smaller than its neighbours implying that it can be equal to them and still qualify for a peak. hence the given algo would work in the sample given by you or any other sample. On Sun, Jun 24,

Re: [algogeeks] Find peak element in log(n)

2012-06-24 Thread Prakhar Jain
The idea behind this O(log n) Divide conquer algorithm is they assumed that element before the first element and after the last element is -infinite. So, they can they always pick the locally rising element ;since, even if the array continues to increase in that half, the last element can be the

Re: [algogeeks] Find peak element in log(n)

2012-06-24 Thread Hassan Monfared
+ Prakhar Jain On Sun, Jun 24, 2012 at 2:03 PM, Prakhar Jain jprakha...@gmail.com wrote: The idea behind this O(log n) Divide conquer algorithm is they assumed that element before the first element and after the last element is -infinite. So, they can they always pick the locally rising

[algogeeks] Is max distance between two leaves(diameter) in a tree is equal to max distance between any two node in that tree??

2012-06-24 Thread Navin Kumar
-- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/xM3mGdcfvi4J. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this

Re: [algogeeks] Find peak element in log(n)

2012-06-24 Thread Anshul Agarwal
can any one expain for 2-D?? On Sun, Jun 24, 2012 at 3:24 PM, Hassan Monfared hmonfa...@gmail.comwrote: + Prakhar Jain On Sun, Jun 24, 2012 at 2:03 PM, Prakhar Jain jprakha...@gmail.comwrote: The idea behind this O(log n) Divide conquer algorithm is they assumed that element before the

[algogeeks] spoj problem EASYMATH

2012-06-24 Thread Sourabh Singh
please suggest something : Problem : http://www.spoj.pl/problems/EASYMATH/ C++ code : http://ideone.com/r2OSb was getting wrong ans due to over flow i think in LCM() for big prime's i guess. thin tried in python . Now getting NZEC for python code which mean's high level or recurrsion some

Re: [algogeeks] spoj problem EASYMATH

2012-06-24 Thread Hassan Monfared
use return (a/gcd(a,b)*b instead On Sun, Jun 24, 2012 at 7:10 PM, Sourabh Singh singhsourab...@gmail.comwrote: please suggest something : Problem : http://www.spoj.pl/problems/EASYMATH/ C++ code : http://ideone.com/r2OSb was getting wrong ans due to over flow i think in LCM() for big

[algogeeks] Re: Reverse Queue

2012-06-24 Thread deepikaanand
code:- http://ideone.com/yMQSK -- 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

Re: [algogeeks] Find the Max from each sub-array of size k

2012-06-24 Thread rajesh pandey
can find one more solution in my blog http://pandey123.wordpress.com/ check it... and tell me if you have any doubt... On Sat, Jun 23, 2012 at 11:52 PM, Akshat Sapra sapraaks...@gmail.comwrote: To do this question in O(n) time follow the post Segment trees in this post of topcoder

Re: [algogeeks] spoj problem EASYMATH

2012-06-24 Thread shady
dont post codes, ask whether your algorithm is correct or not. On Sun, Jun 24, 2012 at 8:29 PM, Hassan Monfared hmonfa...@gmail.comwrote: use return (a/gcd(a,b)*b instead On Sun, Jun 24, 2012 at 7:10 PM, Sourabh Singh singhsourab...@gmail.comwrote: please suggest something : Problem

Re: [algogeeks] 4Sum

2012-06-24 Thread shady
@hemesh, amol = correct solutions ABCDEF another problem on SPOJ, incase people want to try. On Sun, Jun 24, 2012 at 2:13 AM, Sourabh Singh singhsourab...@gmail.comwrote: @ Amol Sharma thanx got it.. yup, overlooked those case's :-) my bad.. On Sat, Jun 23, 2012 at 1:31 PM, Amol Sharma

Re: [algogeeks] Adobe interview question

2012-06-24 Thread himanshu kansal
@rahul: the ques itself says that we have to implement abstract class*without * using pure virtual function... On Sun, Jun 24, 2012 at 12:00 AM, rahul sharma rahul23111...@gmail.comwrote: yeah use pure virtual fxn.. On Fri, Jun 22, 2012 at 3:41 PM, himanshu kansal