Search for question
Question

2. [10 points] Consider the algorithm called SIMPLESORT. Consider two example arrays of size 5 and show the array contents with values of i and j (approximately 25 steps for each example). Does this simple algorithm sort an array of unique elements? Does it sort an array even if there are duplicates? If the algorithm does sort, why do you think it sorts? If the algorithm does not sort an array give a counterexample and you will get 5 extra points as bonus points. SIMPLESORT(A[1...n]) 1. Input: Array to be sorted A[1...n] 2. Output: Sorted array in A[1...n] 3. for 1 to n do 5. 6. for j← 1 to n do if A[i] <A[j] then | SWAP (A[i], A[j])

Fig: 1