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

冒泡排序可以优化 #6

Open
ahong222 opened this issue Apr 14, 2019 · 1 comment
Open

冒泡排序可以优化 #6

ahong222 opened this issue Apr 14, 2019 · 1 comment

Comments

@ahong222
Copy link

冒泡排序,每排一次,最外层的循环可以少一次,不用每次都i < n - 1,除非n--

@Mamong
Copy link

Mamong commented Jul 22, 2019

冒泡法优化方式一:检查本次是否发生交换,不发生就说明已经有序
冒泡法优化方式二:记录上次发生交换的位置,作为本次冒泡的上限

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

No branches or pull requests

2 participants