Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

Jasmine2020
Copy link
Contributor

No description provided.

@Jasmine2020 Jasmine2020 changed the title 作业9 各种排序算法 Homework9 各种排序算法 Jun 14, 2017
int temp = l->data[i];
l->data[i] = l->data[j];
l->data[j] = temp;
(*move)++;
Copy link
Collaborator

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;
}
Copy link
Collaborator

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)
Copy link
Collaborator

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);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 最后,这些排序算法完全可以写在一个程序文件中不同的方法。复用代码更值得去学习。
  • 源程序文件名不要使用中文,注意细节!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants