Write an algorithm/pseudo-code to implement SelectionSort
Algorithm SelectionSort(A[0....n-1])
//A - array of unsorted list
for i <- 0 to n-2 do
begin
min <- i
for j <- i+1 to n-1 do
begin
if A[j] < A[min]
min <- j
end
swap A[min] and A[i]
end
end algorithm
No comments:
Post a Comment