Finding local maxima in a 2D array

前端 未结 7 2093
生来不讨喜
生来不讨喜 2021-02-03 12:39

A local maximum in a 2D array can be defined as a value such that all it\'s 4 neighbours are less than or equal to it, ie, for a[i][j] to be a local maximum,

7条回答
  •  终归单人心
    2021-02-03 13:29

    Just a heads up, local maxima or minima of a 2D grid can be computed in O(nlgn) time using a divide and conquer strategy. This is a slightly better time bound than the brute force algorithm contained in the O(n^2) time complexity class. Furthermore, improvements can be made to the divide and conquer algorithm to obtain an O(n) algorithm for the 2D grid extrema finding.

    Check out these notes on the theory behind such peak picking algorithms (I am sure their are more materials out there):

    http://courses.csail.mit.edu/6.006/spring11/lectures/lec02.pdf

提交回复
热议问题