Skip to content

Latest commit

 

History

History
22 lines (12 loc) · 407 Bytes

README.md

File metadata and controls

22 lines (12 loc) · 407 Bytes

peakFinder

Finds a peak value of a raw integer array

    ¯\_(ツ)_/¯      

Algorithm ologn

[a,b,c,d,e,f,g]

Definition of a peak:

c is a peak if c >= b and c >= d

a is a peak if a >= b

Algorithm

if(array[n/2] < array[n/2 + 1) then check right side for peak

else if (array [n/2] < array[n/2-1] then check left side for peak)

else return array[n/2] peak is found.