Aug 2, 2024
for i from 0 to n-1:
if array[i] == target:
return true
return false
if array[mid] == target:
return true
elif array[mid] < target:
search right half
else:
search left half
for i from 0 to n-1:
find minimum in array[i..n-1]
swap minimum with array[i]
repeat n times:
for i from 0 to n-2:
if array[i] > array[i+1]:
swap(array[i], array[i+1])
if length of array is 1:
return
mid = length of array / 2
sort left half
sort right half
merge_sorted_halves