Re: [algogeeks] correctness of point inside polygon: algorithm ?

2011-12-23 Thread atul anand
Ray casting algorithmn seems fine to mechecked some cases its working good. nice and simple algo. check this link:- http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html#The%20Method On Sun, Dec 18, 2011 at 6:00 PM, WgpShashank shashank7andr...@gmail.comwrote: Would

[algogeeks] Re: correctness of point inside polygon: algorithm ?

2011-12-23 Thread Gene
The description is fine. It is tricky to get implementation exactly right for the cases where the ray pierces a vertex or coincides exactly with an edge, especially with floating point rather than rational arithmetic. Franklin's code (link is given on the page) works well. I'd never code it

[algogeeks] How to solve this

2011-12-23 Thread Ankur Garg
Suggest an algo with which u can find a random node in an infinitely long linked list -- 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

[algogeeks] Re: How to solve this

2011-12-23 Thread Dave
@Ankur: The linked list is isomorphic to the non-negative integers, so selecting a random integer is equivalent to selecting a random node. There is no uniform distribution on the integers, so we can't find a uniform distribution on the nodes. One way to find a non-uniform distribution is by

[algogeeks] Re: How to solve this

2011-12-23 Thread Piyush Kansal
Hey Ankur, What is the order of time complexity we are looking for in this case. The option which Dave suggested can give us random node by traversing that many number of nodes from the head. That will be O(n). This can be further reduced to n/2 if we use two pointers, both of which will

Re: [algogeeks] Re: Facebook Question

2011-12-23 Thread Carol Smith
@Gene - Cool algorithm! I tried before in java and messed a little to get exact output format. Just wondering how you came up with simple yet working code? -Carol On Thu, Dec 22, 2011 at 6:08 PM, Gene gene.ress...@gmail.com wrote: The simplest algorithm is probably to check each point against