Prof. Erik Demaine - Massachusetts Institute of Technology.pdfVIP

  • 17
  • 0
  • 约1.07万字
  • 约 23页
  • 2016-03-09 发布于广东
  • 举报

Prof. Erik Demaine - Massachusetts Institute of Technology.pdf

6.006 Introduction to Algorithms Lecture 2: Peak Finding Prof. Erik Demaine Today • Peak finding (new problem) – 1D algorithms – 2D algorithms • Divide conquer (new technique) Finding Water… IN SPACE • You are GeordiLaForge • Trapped on alien mountain range • Need to find a pool where water accumulates • Can teleport, but can’t see /wiki/File:GeordiLaForge.jpg photo by Erik Demaine Banff, Canada Finding Water… IN SPACE • Problem:Find a local minimum or maximum in a terrain by sampling photo by Erik Demaine Banff, Canada 1D Peak Finding • Given an array : : 1 2 6 5 3 7 4 0 1 2 3 4 5 6 • is a peak if it is not smaller than its neighbor(s): where we imagine • Goal:Find any peak “Brute Force” Algorithm • Test all elements for peakyness for in : if : return : 1 2 6 5 3 7 4 0 1 2 3 4 5 6 Algorithm 1½ • – Global maximum is alocal maximum for in : if : return : 1 2 6 5 3 7 4 0 1 2 3 4 5 6 Cleverer Ide

文档评论(0)

1亿VIP精品文档

相关文档