We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
快速排序,又称划分交换排序。在平均状况下,排序 n 个项目要 O(n·logn) 次比较。在最坏状况下则需要 O(nˆ2) 次比较,但这种状况并不常见。事实上,快速排序通常明显比其他 O(n·logn) 算法更快,因为它的内部循环可以在大部分的架构上很有效率地被实现出来。
Array.prototype.quick_sort = function() { var len = this.length; if (len <= 1) { return this.slice(0); } var left = []; var right = []; var mid = [this[0]]; for (var i = 1; i < len; i++) { if (this[i] < mid[0]) { left.push(this[i]); } else { right.push(this[i]); } } return left.quick_sort().concat(mid.concat(right.quick_sort())); };
The text was updated successfully, but these errors were encountered:
No branches or pull requests
快速排序,又称划分交换排序。在平均状况下,排序 n 个项目要 O(n·logn) 次比较。在最坏状况下则需要 O(nˆ2) 次比较,但这种状况并不常见。事实上,快速排序通常明显比其他 O(n·logn) 算法更快,因为它的内部循环可以在大部分的架构上很有效率地被实现出来。
The text was updated successfully, but these errors were encountered: