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

冒泡排序和快速排序 #10

Open
hello-tsai opened this issue Aug 22, 2019 · 0 comments
Open

冒泡排序和快速排序 #10

hello-tsai opened this issue Aug 22, 2019 · 0 comments

Comments

@hello-tsai
Copy link
Owner

hello-tsai commented Aug 22, 2019

function bubble(arrs) {
for (let i = 0 ; i< arrs.length; i++){
for (let j = 0 ;j<arrs.length-i;j++){
if(arrs[j]>arrs[j+1]){
let temp
temp = arrs[j]
arrs[j] = arrs[j+1]
arrs[j+1] = temp
}
}
console.log(arrs)
}

}
let arrs1 = [4,3,2,1,4,3,2,4,5,74,765,75,3,3,6,5]

bubble(arrs1)

时间复杂度 O(n的平方)
空间复杂度 O(1)

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

1 participant