Re: [algogeeks] Re: Find Largest number in log(n)

2011-12-13 Thread sagar pareek
Thanks Dave, Don and all others for this clarification. On Mon, Dec 12, 2011 at 11:23 PM, Prakash D cegprak...@gmail.com wrote: only the number of comparisons is log(n) On Mon, Dec 12, 2011 at 11:04 PM, Ankur Garg ankurga...@gmail.com wrote: Agree with dave..Its still O(n) On Mon, Dec

[algogeeks] Re: Find Largest number in log(n)

2011-12-12 Thread sagar pareek
I think... First round of tournament sort. :D On Mon, Dec 12, 2011 at 8:02 AM, sagar pareek sagarpar...@gmail.com wrote: Hi every one. Can we find largest number from an unsorted array in log(n) ? -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD --

Re: [algogeeks] Re: Find Largest number in log(n)

2011-12-12 Thread sagar pareek
Yes Mr. DoN First round of Tournament sort results in log(n) time for finding largest no. n/2+n/4+n/8 results n/(2^i) where ^ = power On Mon, Dec 12, 2011 at 8:16 AM, Don dondod...@gmail.com wrote: No. To find the largest number in an unsorted array requires looking at

[algogeeks] Re: Find Largest number in log(n)

2011-12-12 Thread Dave
@Sagar: Don is correct. n/2+n/4+n/8+... ~= n. But even the first round, involving n/2 comparisons, is O(n). Dave On Dec 12, 11:23 am, sagar pareek sagarpar...@gmail.com wrote: Yes Mr. DoN First round of Tournament sort results in log(n) time for finding largest no. n/2+n/4+n/8      

Re: [algogeeks] Re: Find Largest number in log(n)

2011-12-12 Thread Ankur Garg
Agree with dave..Its still O(n) On Mon, Dec 12, 2011 at 10:57 PM, Dave dave_and_da...@juno.com wrote: @Sagar: Don is correct. n/2+n/4+n/8+... ~= n. But even the first round, involving n/2 comparisons, is O(n). Dave On Dec 12, 11:23 am, sagar pareek sagarpar...@gmail.com wrote: Yes Mr.

Re: [algogeeks] Re: Find Largest number in log(n)

2011-12-12 Thread ankit gupta
apply MAXHEAPIFY on root ode and extract the root node -- 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

Re: [algogeeks] Re: Find Largest number in log(n)

2011-12-12 Thread Ankur Garg
Max Heapify is O(n). On Mon, Dec 12, 2011 at 11:43 PM, ankit gupta ankit.itc...@gmail.comwrote: apply MAXHEAPIFY on root ode and extract the root node -- 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: Find Largest number in log(n)

2011-12-12 Thread ankit gupta
maxheapify is lg(n)..check coremen -- 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

Re: [algogeeks] Re: Find Largest number in log(n)

2011-12-12 Thread ankit gupta
http://www.cse.iitk.ac.in/users/dsrkg/cs210/applets/sorting/heapSort/heapSort.html for reference -- 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,

Re: [algogeeks] Re: Find Largest number in log(n)

2011-12-12 Thread Dipit Grover
^it cant get better than O(n) apparently. Just applying max-heapify once would not yield the max element. You need to construct a heap for it, which is no less than O(n). -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group,

[algogeeks] Re: Find Largest number in log(n)

2011-12-12 Thread Gene
Exactly. Really you should see this with almost no thought. It's called an adversary argument and goes like this. Since you don't know the order of elements in A, envision them as being put in order by an adversary that always knows in advance what element you're going to examine next. Now no

Re: [algogeeks] Re: Find Largest number in log(n)

2011-12-12 Thread Ankur Garg
By Max Heapify I thought u meant to say u are making a Max Heap .. In case you use Coreman Definition Of max Heapify it just heapifies assuming the heap has been formed, But u need to make a max Heap first dude :) P.S- Clarify your concepts before posting the link :( On Tue, Dec 13, 2011 at

Re: [algogeeks] Re: Find Largest number in log(n)

2011-12-12 Thread saurabh singh
@all..Well I am no expert but my logic says its impossible to pick the best unless and untill you look at each and every individual.Isn't this logic enough? On Tue, Dec 13, 2011 at 12:32 AM, Ankur Garg ankurga...@gmail.com wrote: By Max Heapify I thought u meant to say u are making a Max Heap

Re: [algogeeks] Re: Find Largest number in log(n)

2011-12-12 Thread Prakash D
only the number of comparisons is log(n) On Mon, Dec 12, 2011 at 11:04 PM, Ankur Garg ankurga...@gmail.com wrote: Agree with dave..Its still O(n) On Mon, Dec 12, 2011 at 10:57 PM, Dave dave_and_da...@juno.com wrote: @Sagar: Don is correct. n/2+n/4+n/8+... ~= n. But even the first round,