This preview shows pages 1–6. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Part I: Divide and Conquer Lecture 2: Maximum Contiguous Subarray Problem Lecture 2: Maximum Contiguous Subarray Problem Part I: Divide and Conquer Introduction to Part I Divide and conquer (D&C) is an important algorithm design paradigm. It works by recursively breaking down a problem into two or more subproblems of the same (or related) type, until these become simple enough to be solved directly. The solutions to the subproblems are then combined to give a solution to the original problem. In Part I, we will illustrate DivideandConquer using several examples: Maximum contiguous subarray Polynomial Multiplication Partition and Selection Lecture 2: Maximum Contiguous Subarray Problem Part I: Divide and Conquer Objective and Outline Objective : Discuss first example of divideandconquer Reference : Chapter 8 in Programming Pearls, (2nd ed) by Jon Bentley Outline: Problem definition A brute force algorithm A datareuse algorithm A divideandconquer algorithm Analysis of the divideandconquer algorithm Summary Lecture 2: Maximum Contiguous Subarray Problem Part I: Divide and Conquer Maximum Contiguous Subarray Problem ACME CORP 1 – PROFIT HISTORY Year 1 2 3 4 5 6 7 8 9 Profit M$3 2 14 5 21 31 Between years 1 and 9: ACME earned 3 + 2 + 1 4 + 5 + 2 1 + 3 1 = 4 M$ Between years 2 and 6: ACME earned 2 + 1 4 + 5 + 2 = 6 M$ Betweeen years 5 and 8: ACME earned 5 + 2 1 + 3 = 9 M$ Problem: Find the span of years in which ACME earned the most Answer: Year 58 , 9 M$ 1 A Company that Makes Everything Lecture 2: Maximum Contiguous Subarray Problem Part I: Divide and Conquer Formal Definition Input : An array of reals A [1 . . . N ] The value of sub array A [ i . . . j ] is V ( i , j ) = j X x = i A ( x ) Definition (Maximum Contiguous Subarray Problem) Find i ≤ j such that V ( i...
View Full
Document
 Spring '07
 ARYA
 Algorithms

Click to edit the document details