Convex Hull | |||||
One Page |
04_run
20161206
Run 1Input:
Output:
Solution: the length of the wire we need to fence off the sheep is: 53.20. Run 2Check if the convex hull implementation is correct by taking as input a list of 1000 random points: Conclusion: yes it's correct, all points fall within or on the convex hull. Run 3And finally, let's take as input a list of 1000 random points from a normal distribution: Alternative implementationHere is a different implementation of the core Graham scan, the same as implemented by Sedgewick in algs4.cs.princeton.edu/99hull/GrahamScan.java.html. Because of the stack operations I find this implementation more difficult to understand, but its big advantage is that it doesn't need to copy the whole points list.
|