lec02 - 6.006 Introduction to Algorithms Lecture 2: Peak...

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
6.006 Introduction to Algorithms Lecture 2: Peak Finding Prof. Erik Demaine
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Today Peak finding (new problem) 1D algorithms 2D algorithms (new technique)
Background image of page 2
Finding Water… IN SPACE You are Geordi LaForge Trapped on alien mountain range Need to find a pool where water accumulates Can teleport, but can’t see http://en.wikipedia.org/wiki/File:GeordiLaForge.jpg photo by Erik Demaine Banff, Canada
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Finding Water… IN SPACE Problem: Find a local minimum or maximum in a terrain by sampling photo by Erik Demaine Banff, Canada
Background image of page 4
1D Peak Finding Given an array : is a peak if it is not smaller than its neighbor(s): where we imagine Goal: Find any peak 1 2 6 5 3 7 4 0123456 :
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
“Brute Force” Algorithm Test all elements for peakyness for in : if : return 1 2 6 5 3 7 4 0123456 :
Background image of page 6
Algorithm 1½ Global maximum is a local maximum for in : if : return 1 2 6 5 3 7 4 0123456 :
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Cleverer Idea Look at any element and its neighbors If peak: return Otherwise: locally rising on some side
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/11/2011 for the course MATH 180 taught by Professor Byrns during the Spring '11 term at Montgomery College.

Page1 / 23

lec02 - 6.006 Introduction to Algorithms Lecture 2: Peak...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online