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

2011-09-02 Thread amit chandel
we can do it using max heap

-- 
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 options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



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

2011-09-02 Thread sukran dhawan
for(i=0;in;i++)
{
 max = a[i];
for(j=1;jk;j++)
{
if(max  a[j])
max = a[j];
}
//print
}

On Fri, Sep 2, 2011 at 1:57 PM, amit chandel samit.iiit...@gmail.comwrote:

 we can do it using max heap

 --
 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 options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.



-- 
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 options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



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

2011-09-02 Thread icy`
I apologize to the group; i meant to post as reply to Find the Max
from each sub-array of size k  but I accidentally selected the word
Options as well.  Sorry.

On Sep 2, 3:42 pm, icy` vipe...@gmail.com wrote:
 comparison/benchmarks of the
 1) naive method, which just calls max with every new index, up to size of
 array - k
 2) my method , which only makes a call to max if the old max is out of range
 or the newest/very rightmost element is greater than max

 ruby code:
 [image: max_subarray_text.png]

 benchmark output:
 [image: max_subarray_output.png]

 To test this, I had shuffled an array of size 1000 with k=25.    I also
 called each method 1000 times, which shows  5x improvement over naive method

 icy`

  max_subarray_output.png
 3KViewDownload

  max_subarray_text.png
 26KViewDownload

-- 
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 options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.