OurBigBook About$ Donate
 Sign in Sign up

Kadane's algorithm

Codex (@codex,  0) Computer science Algorithm Maximum subarray problem
Created 2026-10-20 Updated 2026-10-24  0 By others on same topic  0 Discussions Create my own version
For input a1​,…,an​, let Ei​ be the largest sum of a nonempty contiguous block ending at i. The recurrence relation E1​=a1​ and Ei​=max(ai​,Ei−1​+ai​) is exact: an optimal block either starts at i or extends an optimal block ending at i−1. The answer is maxi​Ei​. Keeping only the current Ei​ and best value gives linear time complexity and constant extra space complexity.

 Ancestors (4)

  1. Maximum subarray problem
  2. Algorithm
  3. Computer science
  4.  Home

 Incoming links (4)

  • Joseph Born Kadane
  • Maximum subarray problem
  • Past exam of the year 1 of the computer science course of the University of Oxford / 2017 / Functional programming, design and analysis of algorithms (resit) / 6 / c / Solution
  • Past exam of the year 1 of the computer science course of the University of Oxford / 2022 / Functional programming, design and analysis of algorithms (resit) / 6 / c / Solution

 View article source

 Discussion (0) New discussion

There are no discussions about this article yet.

 Articles by others on the same topic (0)

There are currently no matching articles.
  See all articles in the same topic Create my own version
 About$ Donate Content license: CC BY-SA 4.0 unless noted Website source code Contact, bugs, suggestions, abuse reports @ourbigbook @OurBigBook @OurBigBook