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

CLRS/C08-Sorting-in-Linear-Time/problem.md 8-3 b #313

Open
Akasakar opened this issue Dec 10, 2019 · 0 comments
Open

CLRS/C08-Sorting-in-Linear-Time/problem.md 8-3 b #313

Akasakar opened this issue Dec 10, 2019 · 0 comments

Comments

@Akasakar
Copy link

不是很理解先reverse再填充空格那句话,最后基数排序完再去掉填充字符,reverse。
感觉例子给出的第二次循环有问题,为什么不是b,c,d,dcb,cb,db,cdb或dcb,cb,db,cdb,b,c,d这样的顺序。
由于answer给出的是空格>字母,第二次循环长度为一的串,第二位应该是空格才对把?第二位同样字符的串在循环结束后应该在相邻位置才对吧?

用空格填充到每个元素等长
字符串中的位置的优先级按照,从左往右递减,比如第i位>第j位(i < j时成立),基数排序时按照优先级从小到大循环。这样处理就和处理等长数字的基数排序一致了。
直接套一个基数排序即可。

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