for(i = 0 ; i < size-1; i++) { for (j = i+1; j < size ; j++) { if (a[i] > a[j]) { swap(a[i],a[j]); } } }
Assume: We can prove directly that a bound on sorting is O(n lg(n)) We know that finding a convex hull is equivelent to sorting To Prove The lower time bound on the convex hull problem is O(n lg(n)) Assume this is false, the lower bound on the convex hull is less than O(n lg(n)), this means that we can find the couvex hull of a set of points in less than O(n lg(n)) time, which implys that we can sort n integers in less than 0(n lg(n)) time, which is a contradiction, therefore the lower bound on sorting is O(n lg(n)).
S0: Vacuosly, a single element array is in order. Si: We know that the array up to position i is in order, and that the element at position i-1 is the largest. If the element at position i is larger thant this, the array is still in order and the value of the variable is not changed, if it is smaller, the value of the variable is changed, and the the proposition no longer holds.