문제

I have a set of strings say Set S = {string1, string2 ... upto N }. I need to sort them lexicographically.

How to use bucket sort to do so ?

Also tell any other efficient method that can be used to solve the question.

도움이 되었습니까?

해결책

Sort by the first character. This gives you some number of "buckets." Sort each nonempty bucket starting with the second character. Repeat until the whole thing is sorted.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top