Lecture 20: Peak Finding in 2D
COMS10007 - Algorithms
- Dr. Christian Konrad
30.04.2019
- Dr. Christian Konrad
Lecture 20: Peak Finding in 2D 1 / 14
Lecture 20: Peak Finding in 2D COMS10007 - Algorithms Dr. Christian - - PowerPoint PPT Presentation
Lecture 20: Peak Finding in 2D COMS10007 - Algorithms Dr. Christian Konrad 30.04.2019 Dr. Christian Konrad Lecture 20: Peak Finding in 2D 1 / 14 Peak Finding Let A = a 0 , a 1 , . . . , a n 1 be an array of integers of length n 0 1 2
Lecture 20: Peak Finding in 2D 1 / 14
Lecture 20: Peak Finding in 2D 2 / 14
Lecture 20: Peak Finding in 2D 2 / 14
Lecture 20: Peak Finding in 2D 3 / 14
Lecture 20: Peak Finding in 2D 4 / 14
Lecture 20: Peak Finding in 2D 4 / 14
Lecture 20: Peak Finding in 2D 5 / 14
1 Check whether A[⌊n/2⌋] is a peak, if yes then return A[⌊n/2⌋] 2 Else, if A[⌊n/2⌋ − 1] > A[⌊n/2⌋] then recursively find a peak
3 Else, recursively find a peak in A[⌊n/2⌋ + 1, n − 1]
Lecture 20: Peak Finding in 2D 6 / 14
Lecture 20: Peak Finding in 2D 7 / 14
2 −1
2
2 +1
2 −1
2
2 +1
2 −1
2
2 +1
2 −1
2
2 +1
Lecture 20: Peak Finding in 2D 8 / 14
2 −1
2 −1
2 −1
2 −1
Lecture 20: Peak Finding in 2D 8 / 14
2 −1
2
2 +1
2 −1
2
2 +1
2 −1
2
2 +1
2 −1
2
2 +1
Lecture 20: Peak Finding in 2D 9 / 14
2 −1
2
2 +1
2 −1
2
2 +1
2 −1
2
2 +1
2 −1
2
2 +1
Lecture 20: Peak Finding in 2D 9 / 14
2 −1
2
2 +1
2 −1
2
2 +1
2 −1
2
2 +1
2 −1
2
2 +1
Lecture 20: Peak Finding in 2D 9 / 14
2 −1
2
2 +1
2 −1
2
2 +1
2 −1
2
2 +1
2 −1
2
2 +1
Lecture 20: Peak Finding in 2D 10 / 14
2 −1
2
2 +1
2 −1
2
2 +1
2 −1
2
2 +1
2 −1
2
2 +1
Lecture 20: Peak Finding in 2D 10 / 14
2 −1
2
2 +1
2 −1
2
2 +1
2 −1
2
2 +1
2 −1
2
2 +1
Lecture 20: Peak Finding in 2D 10 / 14
2 −1
2
2 +1
2 −1
2
2 +1
2 −1
2
2 +1
2 −1
2
2 +1
Lecture 20: Peak Finding in 2D 11 / 14
Lecture 20: Peak Finding in 2D 12 / 14
Lecture 20: Peak Finding in 2D 13 / 14
Lecture 20: Peak Finding in 2D 14 / 14