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

希尔排序 js写法 for 循环i 的增加有优化的空间 #53

Open
wujiahui1 opened this issue Jan 31, 2021 · 1 comment
Open

希尔排序 js写法 for 循环i 的增加有优化的空间 #53

wujiahui1 opened this issue Jan 31, 2021 · 1 comment

Comments

@wujiahui1
Copy link

for(let i = gap; i < len; i +=gap) {

@zcoding
Copy link

zcoding commented Aug 9, 2021

写成 i += gap 说明理解不到位
gap 为1时,i += gap 没问题;
gap 大于1时,for (let i = gap; i < len; i += gap) 直到循环结束只处理了1组数据而已,但实际上有 gap 组数据。其它组数据怎么遍历呢?就是把 i += gap 改为 i++i++ 可以保证 i 之前的数据,在它们各自的分组里面,都已经处理过了。

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