Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

Algorithms/Find maximum/Python method 2

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

Python (2.6) source code. def findMax(a): length = len(a) if length == 0 : return 0 elif length == 1 : return a[0] elif length == 2 : if a[0] > a[1] : return a[0] else : return a[1] half = length / 2 list_A = a[:half] list_B = a[half:] max_A = findMax(list_A) max_B = findMax(list_B) if max_A > max_B : return max_A else : return max_B