Re: [algogeeks] Give Algo to do this in O(n)

2011-10-10 Thread sandeep nagamalli
@Shiva: How can min heap be uesd, can you eloborate a bit.

As far as i see, the best possible is O(nlogn) i.e by sorting and scanning
over the complete array once.



On Mon, Oct 10, 2011 at 9:49 AM, shiva@Algo shiv.jays...@gmail.com wrote:

 I think Min heap will do that..


 On Mon, Oct 10, 2011 at 12:37 AM, Ankur Garg ankurga...@gmail.com wrote:

 Given an unsorted array of Integers

 Find 2 nos whose diff is minimum

 Say Array is  4 2 18 19 11 8 5

 Nos are 18 and 19

 Algo shud be of O(n)

 --
 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.




-- 
ThanksRegards:
-sandeep

-- 
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: google maps

2011-09-20 Thread sandeep nagamalli
Well, I think its not that the algorithm be written with all Google maps
features in place. Rather it is a open ended question, where interviewer is
trying to find
the candidates view of algorithm design.
@Deepak: It should be fine even if some reasonably good algo is given.

my 2 cents:
For the shortest route finding feature:
I would say: Create a graph with nodes as stations and graphs as the
roads/paths between station. Now Dijkstra's algo can be used to find the
shortest path


On Tue, Sep 20, 2011 at 10:03 PM, Deepak Garg deepakgarg...@gmail.comwrote:

 they are using a highly optimized A* algo for rout finding


 On Tue, Sep 20, 2011 at 10:01 PM, Dave dave_and_da...@juno.com wrote:

 @Sukran: Well, I would hire about 1000 smart people and let them do
 it. :-)

 Dave

 On Sep 20, 2:12 am, sukran dhawan sukrandha...@gmail.com wrote:
  How do you implement google maps ?

 --
 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.




 --
 U.D.I.T

 Sent by Nokia OVI (c)

  --
 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] ms question

2011-09-12 Thread sandeep nagamalli
I think it is 1 / (2N)

(1/N) * (1/N)*(N/2) = 1/(2N)

On Mon, Sep 12, 2011 at 6:33 PM, Akash Mukherjee akash...@gmail.com wrote:

 this is a case, but isnt der a case of circular permutation 2??
 what say abt dis
 0,1
 2,3
 4,5
 0,1
 2,3
 4,5

 it wrks i gues??


 On Mon, Sep 12, 2011 at 12:56 PM, teja bala pawanjalsa.t...@gmail.comwrote:



 I think it is 1/N

  let N=6 that means rand(6)= takes values 0-5 i.e 6 values.
 rand(m)=6 values
 rand(n)=6 values
 total combinations 6*6=36 values set but among dem array will change only
 for
 (0,0)(1,1)(2,2)(3,3)(4,4)(5,5)(6,6)=6values of N

 So 6/36=1/6

 If we generalize it 1/N

 correct me if i'm wrong?

 --
 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.




-- 
ThanksRegards:
-sandeep

-- 
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.