I'm looking for a single recursive structure algorithm to find both maximum and minimum values of an array. I've found the following pseudocode on here:
FindMaxAndMin(A, max, min)
if (|A| == 1)
if (max < A[1])
max = A[1]
if (min > A[1])
min = A[1]
return (min, max)
cen = |A| /2
l = A[:cen-1]
h = A[cen:]
(min, max) = FindMaxAndMin(l, min, max)
(min, max) = FindMaxAndMin(h, min, max)
return (min, max)
So I was wondering firstly if this counts as a single recursive structure as it all takes place under the first if. If this is a single recursive structure, I was firstly wondering what |A| represents, can't find it anywhere online, and how would it work call by call when A = (3,2,4,1) for example?
|A|is the cardinality (quantity of elements) ofA.