Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Efficient Peak Finding: Solving Problems in 1D and 2D, Lecture notes of Microcomputers

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

2018/2019

Uploaded on 11/03/2019

yashasvi-pandey
yashasvi-pandey 🇮🇳

1 document

1 / 6

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Lecture 1 Introduction and Peak Finding 6.006 Fall 2011
Lecture 1: Introduction and Peak Finding
Lecture Overview
Administrivia
Course Overview
“Peak finding” problem 1D and 2D versions
Course Overview
This course covers:
Efficient procedures for solving problems on large inputs (Ex: U.S. Highway Map,
Human Genome)
Scalability
Classic data structures and elementary algorithms (CLRS text)
Real implementations in Python
Fun problem sets!
The course is divided into 8 modules each of which has a motivating problem and problem
set(s) (except for the last module). Tentative module topics and motivating problems are
as described below:
1. Algorithmic Thinking: Peak Finding
2. Sorting & Trees: Event Simulation
3. Hashing: Genome Comparison
4. Numerics: RSA Encryption
5. Graphs: Rubik’s Cube
6. Shortest Paths: Caltech MIT
7. Dynamic Programming: Image Compression
8. Advanced Topics
1
pf3
pf4
pf5

Partial preview of the text

Download Efficient Peak Finding: Solving Problems in 1D and 2D and more Lecture notes Microcomputers in PDF only on Docsity!

Lecture 1: Introduction and Peak Finding

Lecture Overview

  • Administrivia
  • Course Overview
  • “Peak finding” problem — 1D and 2D versions

Course Overview

This course covers:

  • Efficient Human Genome) procedures for solving problems on large inputs (Ex: U.S. Highway Map,
  • Scalability
  • Classic data structures and elementary algorithms (CLRS text)
  • Real implementations in Python
  • Fun problem sets! The set(s) course (except is divided for the into last (^8) module). modules —Tentative each of whichmodule has topics a motivating and motivating problem problemsand problem are as described below:
  1. Algorithmic Thinking: Peak Finding
  2. Sorting & Trees: Event Simulation
  3. Hashing: Genome Comparison
  4. Numerics: RSA Encryption
  5. Graphs: Rubik’s Cube
  6. Shortest Paths: Caltech → MIT
  7. Dynamic Programming: Image Compression
  8. Advanced Topics

Peak Finder

One-dimensional Version

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

i

j = m/

  • Pick middle column j = m/2.
  • Find a 1D-peak at i, j.
  • Use (i, j) as a start point on row i to find 1D-peak on row i. Attempt #1 fails Problem: 2D-peak may not exist on row i

End up with 14 which is not a 2D-peak.

Attempt # 2

  • Pick middle column j = m/ 2
  • Find global maximum on column j at (i, j)
  • Compare (i, j − 1), (i, j), (i, j + 1)
  • Pick left columns of (i, j − 1) > (i, j)
  • Similarly for right
  • (i, j) is a 2D-peak if neither condition holds ← WHY?
  • Solve the new problem with half the number of columns.
  • When you have a single column, find global maximum and you‘re done. Example of Attempt #

pick this column17 global max

for this column

pick this column19 global max

for this column

21 find 21

go with

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