-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Homework9 各种排序算法 #176
base: master
Are you sure you want to change the base?
Homework9 各种排序算法 #176
Conversation
int temp = l->data[i]; | ||
l->data[i] = l->data[j]; | ||
l->data[j] = temp; | ||
(*move)++; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 一次交换的移动次数是3次
temp = l->data[j - gap]; | ||
l->data[j - gap] = l->data[j]; | ||
l->data[j] = temp; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 希尔排序未做任何比较次数和移动次数的计算
min = j; | ||
} | ||
} | ||
if (min != i) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
第i趟简单选择排序是指通过n−i次关键字的比较,从n−i+1个记录中选出关键字最小的记录,并与第i个记录进行交换
- 你这样写也能排序成功,但是已经脱离选择排序的初衷了
printf("\nAfter Sort:\n"); | ||
Print(&L); | ||
printf("\ncompare time:%d\nmove time:%d\n", compare, move); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 最后,这些排序算法完全可以写在一个程序文件中不同的方法。复用代码更值得去学习。
- 源程序文件名不要使用中文,注意细节!
No description provided.