Teaser robustness lecture Convex hull Buggy degenerate example (single precision) w 1 = (12 , 12) w 2 = (24 , 24) w 3 = (30 , 30 . 000001) w 4 = (23 , 36) w 5 = (0 . 5000029 , 0 . 5000027) Do n = first in S ; For each w ∈ S u if vwn positive then n = w ; v.next = n ; v = n ; S = S \ { v } While v � = u 8 - 3
Teaser robustness lecture Convex hull Buggy degenerate example (single precision) w 1 = (12 , 12) w 2 = (24 , 24) w 3 = (30 , 30 . 000001) w 4 = (23 , 36) w 5 = (0 . 5000029 , 0 . 5000027) n Do n = first in S ; For each w ∈ S u = v if vwn positive then n = w ; v.next = n ; v = n ; S = S \ { v } While v � = u 8 - 4
Teaser robustness lecture Convex hull Buggy degenerate example (single precision) w 1 = (12 , 12) w 2 = (24 , 24) w 3 = (30 , 30 . 000001) w w 4 = (23 , 36) w 5 = (0 . 5000029 , 0 . 5000027) n Do n = first in S ; For each w ∈ S u = v if vwn positive then n = w ; v.next = n ; v = n ; S = S \ { v } While v � = u 8 - 5
Teaser robustness lecture Convex hull Buggy degenerate example (single precision) w 1 = (12 , 12) w 2 = (24 , 24) w w 3 = (30 , 30 . 000001) n w 4 = (23 , 36) w 5 = (0 . 5000029 , 0 . 5000027) n Do n = first in S ; For each w ∈ S u = v if vwn positive then n = w ; v.next = n ; v = n ; S = S \ { v } While v � = u 8 - 6
Teaser robustness lecture Convex hull Buggy degenerate example (single precision) w w 1 = (12 , 12) w 2 = (24 , 24) w 3 = (30 , 30 . 000001) n w 4 = (23 , 36) w 5 = (0 . 5000029 , 0 . 5000027) n Do n = first in S ; For each w ∈ S u = v if vwn positive then n = w ; v.next = n ; v = n ; S = S \ { v } While v � = u 8 - 7
Teaser robustness lecture Convex hull Buggy degenerate example (single precision) w 1 = (12 , 12) w 2 = (24 , 24) w 3 = (30 , 30 . 000001) n w 4 = (23 , 36) w 5 = (0 . 5000029 , 0 . 5000027) n Do n = first in S ; For each w ∈ S u = v = w if vwn positive then n = w ; v.next = n ; v = n ; S = S \ { v } While v � = u 8 - 8
Teaser robustness lecture Convex hull Buggy degenerate example (single precision) w 1 = (12 , 12) w 2 = (24 , 24) v w 3 = (30 , 30 . 000001) w 4 = (23 , 36) w 5 = (0 . 5000029 , 0 . 5000027) n Do n = first in S ; For each w ∈ S u if vwn positive then n = w ; v.next = n ; v = n ; S = S \ { v } While v � = u 8 - 9
Teaser robustness lecture Convex hull Buggy degenerate example (single precision) w 1 = (12 , 12) w w 2 = (24 , 24) v w 3 = (30 , 30 . 000001) w 4 = (23 , 36) w 5 = (0 . 5000029 , 0 . 5000027) n Do n = first in S ; For each w ∈ S u if vwn positive then n = w ; v.next = n ; v = n ; S = S \ { v } While v � = u 8 - 10
Teaser robustness lecture Convex hull Buggy degenerate example (single precision) w 1 = (12 , 12) w w 2 = (24 , 24) v w 3 = (30 , 30 . 000001) w 4 = (23 , 36) w 5 = (0 . 5000029 , 0 . 5000027) n Do n = first in S ; For each w ∈ S u if vwn positive then n = w ; v.next = n ; v = n ; Incoherence S = S \ { v } While v � = u 8 - 11
Teaser robustness lecture Convex hull Buggy degenerate example (single precision) w w 1 = (12 , 12) w 2 = (24 , 24) v w 3 = (30 , 30 . 000001) w 4 = (23 , 36) w 5 = (0 . 5000029 , 0 . 5000027) n Do n = first in S ; For each w ∈ S u if vwn positive then n = w ; v.next = n ; v = n ; S = S \ { v } While v � = u 8 - 12
Teaser robustness lecture Convex hull Buggy degenerate example (single precision) n w 1 = (12 , 12) w 2 = (24 , 24) v w 3 = (30 , 30 . 000001) w 4 = (23 , 36) w 5 = (0 . 5000029 , 0 . 5000027) Do n = first in S ; For each w ∈ S = w u if vwn positive then n = w ; v.next = n ; v = n ; S = S \ { v } While v � = u 8 - 13
Teaser robustness lecture Convex hull Buggy degenerate example (single precision) v w 1 = (12 , 12) w 2 = (24 , 24) w w 3 = (30 , 30 . 000001) w 4 = (23 , 36) w 5 = (0 . 5000029 , 0 . 5000027) n Do n = first in S ; For each w ∈ S u if vwn positive then n = w ; v.next = n ; v = n ; S = S \ { v } While v � = u 8 - 14
Teaser robustness lecture Convex hull Buggy degenerate example (single precision) v w 1 = (12 , 12) w 2 = (24 , 24) w 3 = (30 , 30 . 000001) w 4 = (23 , 36) w 5 = (0 . 5000029 , 0 . 5000027) n Do n = first in S ; For each w ∈ S u = w if vwn positive then n = w ; v.next = n ; v = n ; S = S \ { v } While v � = u 8 - 15
Teaser robustness lecture Convex hull Buggy degenerate example (single precision) w 1 = (12 , 12) w 2 = (24 , 24) w 3 = (30 , 30 . 000001) w 4 = (23 , 36) u = w 5 = (0 . 5000029 , 0 . 5000027) Do n = first in S ; For each w ∈ S u if vwn positive then n = w ; v.next = n ; v = n ; S = S \ { v } While v � = u 8 - 16
Teaser robustness lecture Convex hull Buggy degenerate example (single precision) w 1 = (12 , 12) w 2 = (24 , 24) w 3 = (30 , 30 . 000001) w 4 = (23 , 36) w 5 = (0 . 5000029 , 0 . 5000027) u Result is really wrong 8 - 17
Real RAM model and Convex hull general position hypothesis Real Random Access Memory model Assume exact computation on real numbers constant time for single operations: + , − , √ , sin . . . 9 - 1
Real RAM model and Convex hull general position hypothesis Real Random Access Memory model Assume exact computation on real numbers constant time for single operations: + , − , √ , sin . . . General position hypotheses Predicate: Input �− → {− 1 , 0 , 1 } 9 - 2
Real RAM model and Convex hull general position hypothesis Real Random Access Memory model Assume exact computation on real numbers constant time for single operations: + , − , √ , sin . . . General position hypotheses Predicate: Input �− → {− 1 , 0 , 1 } 2D convex hull: no three points colinear 9 - 3
Real RAM model and Convex hull general position hypothesis Real Random Access Memory model Assume exact computation on real numbers constant time for single operations: + , − , √ , sin . . . General position hypotheses Predicate: Input �− → {− 1 , 0 , 1 } 2D convex hull: no three points colinear possibly: no 2 points with same x 9 - 4
Convex hull Graham algorithm 10 - 1
Convex hull Graham algorithm sort around a point (e.g. lowest point) 10 - 2
Convex hull Graham algorithm sort around a point (e.g. lowest point) 10 - 3
Convex hull Graham algorithm leftturn OK 10 - 4
Convex hull Graham algorithm rightturn remove and go back 10 - 5
Convex hull Graham algorithm leftturn OK 10 - 6
Convex hull Graham algorithm leftturn OK 10 - 7
Convex hull Graham algorithm leftturn OK 10 - 8
Convex hull Graham algorithm rightturn remove and go back 10 - 9
Convex hull Graham algorithm rightturn remove and go back 10 - 10
Convex hull Graham algorithm leftturn OK 10 - 11
Convex hull Graham algorithm leftturn OK 10 - 12
Convex hull Graham algorithm rightturn remove and go back 10 - 13
Convex hull Graham algorithm leftturn OK 10 - 14
Convex hull Graham algorithm leftturn OK 10 - 15
Convex hull Graham algorithm 10 - 16
Complexity Convex hull Graham algorithm Input: point set S u lowest point of S ; sort S around u in a circular list including u ; v = u ; while v.next � = u if ( v, v.next, v.next.next ) ccw v = v.next ; else v.next = v.next.next ; v.next.previous = v ; if v � = u v = v.previous ; 11 - 1
Complexity Convex hull Graham algorithm Input: point set S O ( n ) u lowest point of S ; sort S around u in a circular list including u ; v = u ; while v.next � = u if ( v, v.next, v.next.next ) ccw v = v.next ; else v.next = v.next.next ; v.next.previous = v ; if v � = u v = v.previous ; 11 - 2
Complexity Convex hull Graham algorithm Input: point set S u lowest point of S ; O ( n log n ) sort S around u in a circular list including u ; v = u ; while v.next � = u if ( v, v.next, v.next.next ) ccw v = v.next ; else v.next = v.next.next ; v.next.previous = v ; if v � = u v = v.previous ; 11 - 3
Complexity Convex hull Graham algorithm Input: point set S u lowest point of S ; sort S around u in a circular list including u ; v = u ; while v.next � = u if ( v, v.next, v.next.next ) ccw v = v.next ; else v.next = v.next.next ; v.next.previous = v ; if v � = u v = v.previous ; 11 - 4
Complexity Convex hull Graham algorithm Input: point set S u lowest point of S ; sort S around u in a circular list including u ; v = u ; while v.next � = u if ( v, v.next, v.next.next ) ccw v = v.next ; else v.next = v.next.next ; v.next.previous = v ; if v � = u v = v.previous ; delete one point at most n times 11 - 5
Complexity Convex hull Graham algorithm Input: point set S u lowest point of S ; sort S around u in a circular list including u ; v = u ; distance to u decreases at most n times while v.next � = u if ( v, v.next, v.next.next ) ccw v = v.next ; else v.next = v.next.next ; v.next.previous = v ; if v � = u v = v.previous ; delete one point at most n times 11 - 6
Complexity Convex hull Graham algorithm Input: point set S u lowest point of S ; sort S around u in a circular list including u ; v = u ; distance to u decreases O ( n ) at most n times while v.next � = u if ( v, v.next, v.next.next ) ccw v = v.next ; else v.next = v.next.next ; v.next.previous = v ; if v � = u v = v.previous ; delete one point at most n times 11 - 7
Complexity Convex hull Graham algorithm Input: point set S u lowest point of S ; sort S around u in a circular list including u ; v = u ; O ( n log n ) while v.next � = u if ( v, v.next, v.next.next ) ccw v = v.next ; else v.next = v.next.next ; v.next.previous = v ; if v � = u v = v.previous ; 11 - 8
Convex hull Lower bound Problem lower bound is Ω( f ( n )) Iff there is NO algorithm solving all size n problems using less than Cf ( n ) operations ∀ n C constant independent of n 12
Sorting Lower bound Input: n real (positive) numbers 13 - 1
Sorting Lower bound Input: n real (positive) numbers Output: sorting permutation 13 - 2
Sorting Lower bound Input: n real (positive) numbers Output: sorting permutation Monitoring execution 13 - 3
Sorting Lower bound Input: n real (positive) numbers Output: sorting permutation Yes No Monitoring execution 13 - 4
Sorting Lower bound Input: n real (positive) numbers Output: sorting permutation Yes No Monitoring execution 13 - 5
Sorting Lower bound Input: n real (positive) numbers Output: sorting permutation Yes No Monitoring execution 13 - 6
Sorting Lower bound Input: n real (positive) numbers Output: sorting permutation Yes No Monitoring execution ♯ leaves ≥ ♯ permutations 13 - 7
Sorting Lower bound Input: n real (positive) numbers Output: sorting permutation Yes No Monitoring execution ♯ leaves ≥ ♯ permutations There are n ! permutations 13 - 8
Sorting Lower bound Input: n real (positive) numbers Output: sorting permutation Yes No Monitoring execution ♯ leaves ≥ ♯ permutations There are n ! permutations Tree height is at least log 2 ♯ leaves 13 - 9
Sorting Lower bound Input: n real (positive) numbers Output: sorting permutation Yes No Monitoring execution ♯ leaves ≥ ♯ permutations There are n ! permutations Tree height is at least log 2 ♯ leaves ♯ comparisons ≤ log 2 n ! ≃ n log 2 n 13 - 10
Convex hull Lower bound Input: n 2D points (real coordinates) Output: list of points along the convex hull 14 - 1
Convex hull Lower bound A stupid algorithm for sorting numbers 14 - 2
Convex hull Lower bound project on parabola 14 - 3
Convex hull Lower bound project on parabola compute convex hull 14 - 4
Convex hull Lower bound project on parabola compute convex hull find lowest point 14 - 5
Recommend
More recommend