Skip to content

Repository files navigation

MaximumSubarray

Maximum subarray problem. Brute Force, Divide and Conquer, Kadane's Algorithm

More info: https://www.mycertnotes.com/az/maximum-subarray-problemi-kadane-alqoritmi/


The following stock problem is given in Introduction to Algorithms book (on page 68), you can solve it using "Maximum-subarray":

maximum-subarray-practical-example


It is shown three solution for maximum-subarray problem in this project:

NAlgorithmTime complexity
1Brute-forceO(n^2)
2Divide and ConquerO(nlogn)
3Kadane's AlgorithmO(n)

I compared these three solutions in my local machine and result was (duration is given with milliseconds):

Array lengthBrute-forceDivide and ConquerKadane's Algorithm
100013 ms2 ms1 ms
1_000_000646535 ms115 ms9 ms

Time complexity:

time-complexity

Releases

Packages

Contributors

Languages