Consider IsInOrder
inorder = true (1) [1]
i=0; (1) [1]
top: if(i>arraysize) goto out (2) [size+1]
if (array[i] > array[i+1] goto next (4) [size]
inorder = false (1) [?]
next: i = i + 1 (2) [size]
goto top (1) [size]
out:
We can assume either
i: the array is in order and the 5th
statement is always executed.
ii: the array is not in order and the 5th
statement is never executed.
iii: Something inbetween.
Execution time = 1*1+1*1 + 2*(size+1) + 4*size+ 0*1 + 2*size + 1*size
= 4+9*size
or
= 4+10*size
or
= 4+9.5*size