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

前端基础算法——选择排序 - ZHE LIN #10

Closed
ZhelinCheng opened this issue Jul 17, 2019 · 0 comments
Closed

前端基础算法——选择排序 - ZHE LIN #10

ZhelinCheng opened this issue Jul 17, 2019 · 0 comments

Comments

@ZhelinCheng
Copy link
Owner

https://zhelin.me/post/0882e6eb04f593718090cbc83ce329f5/

选择排序,运行时间:O(n^2) // 找出数组中最小的数字 function findSmallest (arr) { let minValue = arr[0] let minIndex = 0 for (let i in arr) { let item = arr[i] if (item >= minValue) { continue } minIndex = i minValue = item } return minIndex } // 对数字进行排序 function selectionSort (arr) { let len = arr.length let newArr = [] for (let i = 0;

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

No branches or pull requests

1 participant