Re: [algogeeks] max path

2013-05-02 Thread Sharath Channahalli
I think this can be converted into Dijkstra's algorithm to find the minimum
distance between the start and end points. (the weights would be negative
of the points between two cells).


On Mon, Apr 29, 2013 at 4:12 PM, sreekanth guru wrote:

>
> Problem:
>
> We have m * n grids. Each grid can have one of earth/water/mines. You can
> go to top/bottom/left/right adjacent grids. You can go to adjacent grids
> only when it is filled with earth/mines. you can't travers water filled
> grids. To travel to adjacent grid you need to sacrifice 2 points. If you
> travers mines(each mine will have some positive score) the points in that
> mine will be added to your score. Now given any starting position find out
> max score loop(end point should be same as start point).
>
> P.S. - All mine grid points can be used only once. If you traverse mine
> second time you won't get any points.
>
>
> -sree
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to algogeeks+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to algogeeks+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [algogeeks] Re: Finding elements near the median

2011-01-26 Thread Sharath Channahalli
a) Find the median - O(n)
b) remove the element and again find the median
c) conitnue b until you get k-1 elements

time complexity - kO(n)

On Wed, Jan 26, 2011 at 9:55 PM, ritu  wrote:

>
> solution is nice!!but How to keep track of k closet numbers?
>
>
> On Jan 23, 9:22 pm, ritesh  wrote:
> > 1.) find x= median in o(n)
> > 2.) subtract x from each number of the array
> > 3.) find the k smallest number using o(n) algrithm
> >
> > On Jan 21, 4:04 am, snehal jain  wrote:
> >
> > > Given an unsorted array A of n distinct numbers and an integer k where
> > > 1 <= k <= n, design an algorithm that finds the k numbers in A that
> > > are closest in value to the median of A in O(n) time.
> >
> >
>
> --
> 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.



Re: [algogeeks] Re: Bit Manipulation

2011-01-17 Thread Sharath Channahalli
I think Q1 is NP hard problem since the number of bits grows exponentially
as the array size increases.

On Mon, Jan 17, 2011 at 1:13 PM, juver++  wrote:

> @awesomeandroid
> Your solution for Q1 is wrong. It can be applied only for such numbers N =
> 2^k, so number should power of 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 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.