Sorting algorithms/Heapsort: Difference between revisions

Content added Content deleted
Line 940: Line 940:
is_sorted (ar: ARRAY [INTEGER]): BOOLEAN
is_sorted (ar: ARRAY [INTEGER]): BOOLEAN
--- Is 'ar' sorted in ascending order?
--- Is 'ar' sorted in ascending order?
require
ar_not_empty: ar.is_empty = False
local
local
i: INTEGER
i: INTEGER
Line 949: Line 947:
i := ar.lower
i := ar.lower
until
until
i = ar.upper
i >= ar.upper
loop
loop
if ar [i] > ar [i + 1] then
if ar [i] > ar [i + 1] then