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

fix:quick-sort-code-mistakes #193

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

Conversation

Sociosarbis
Copy link

首先原来的295行是少了个参数的。那按照我的理解,这里应该是将随机位置元素交换到最右边。
然后重新把改过的代码运行发现sort([4,3,5,5,4,5])是会得到[3,4,5,5,4,5]的,那按照我的理解,应该需要加上308行这样,去交换小于基准值和等于基准值两者的位置。

首先原来的295行是少了个参数的。那按照我的理解,这里应该是将随机位置元素交换到最右边。
然后重新把改过的代码运行发现sort([4,3,5,5,4,5])是会得到[3,4,5,5,4,5]的,那按照我的理解,应该需要加上308行这样,去交换小于基准值和等于基准值两者的位置。因为left是是小于等于基准值的,而less是小于基准值。
与上次修改的原因一样
getLeft 和 getRight 如果该节点分别没有左节点和有节点,应该返回他本身吧。predecessor和successor的while的condition应该是在找到位置符合的时候停止,所以应该取反。
new MessageChannel返回的是两个message ports,所以不能这样使用。
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.

None yet

1 participant