Hello Seem to be a hardest word

Just another WordPress.com weblog

Shaker Sort

O(n2)

void ShakerSort(int m[],int n)
{
int left,right,idx,i;
left = 0;
right = n-1;
idx = n-1;
do
{
for(i=right;i>0;i–)
if(comparer(m[i-1],m[i]))
{
swap(m[i],m[i-1]);
idx = i;
}
left = idx;
for(i=left;i<right;i++)
if(comparer(m[i],m[i+1]))
{
swap(m[i],m[i+1]);
idx = i;
}
right = idx;
}
while(left<right);
}

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