



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
An introduction to the peak finding problem in one and two dimensions. It covers the straightforward algorithm for finding a peak in a one-dimensional array, its complexity, and an improvement using divide and conquer. The document also discusses the failure of extending the one-dimensional divide and conquer algorithm to two dimensions and an alternative approach using attempt #2. The complexity of attempt #2 is analyzed, and a question is posed about replacing global maximum with 1d-peak in attempt #2.
Typology: Lecture notes
1 / 6
This page cannot be seen from the preview
Don't miss anything!
This course covers:
Position 2 is a peak if and only if b ≥ a and b ≥ c. Position 9 is a peak if i ≥ h.
a^1 b^2 c^3 d^4 e^5 6 f g^7 h^8 i^9 Figure 1: a-i are numbers Problem: Find a peak if it exists (Does it always exist?) Straightforward Algorithm
Start from left
1 2... n/2 n-1 n might be peak
θ(n) complexity worst case
...
Figure 2: Look at n/ 2 elements on average, could look at n elements in the worst case What Would if we we have start to in ever the middle?look at more For thethan configuration n/ 2 elements below, if we westart would in the look middle, at n/ 2 and elements. choose a direction based on which neighboring element is larger that the middle element? n/
Figure 5: Circled value is peak. Attempt # 1: Extend 1D Divide and Conquer to 2D
End up with 14 which is not a 2D-peak.
Attempt # 2
Complexity of Attempt # If T (n, m) denotes work required to solve problem with n rows and m columns T (n, m) = T (n, m/2) + Θ(n) (to find global maximum on a column — (n rows)) T (n, m) = Θ( ' n) +.. .-v + Θ(n)" = Θ(n log^ log m^ m) = Θ(n log n) if m = n Question: work? What if we replaced global maximum with 1D-peak in Attempt #2? Would that