Hello Seem to be a hardest word

Just another WordPress.com weblog

Selection Sort

THe complexity of best case is the same with worst case’s ones : O(n2)

void SelectionSort(int arr[],int n)
{
int idx;
for(int i=0;i<n-1;i++)
{
idx=i;
for(int j=i+1;j<n;j++)
if(comparer(arr[idx],arr[j]))
idx = j;
if(idx>i)
swap(arr[idx],arr[i]);
}
}

Tháng Sáu 20, 2008 - Đăng bởi fate | Sort Algorithm | | No Comments Yet

Chưa có phản hồi.

Để lại phản hồi

Bạn phải đăng nhập để gửi phản hồi