Home >Web Front-end >JS Tutorial >Javascript implements binary search method implementation code_javascript skills
Generally, int[] type is used for binary classification... In js, it may be more flexibly used as a-z, or pinyin... or...
However, a question worth pondering is whether it is worthwhile to go through the following process in order to achieve binary search for pinyin and the like:
1. Sorting pinyin seems to require a lot of code.
2. Then do a binary search. This requires identifying the size of Pinyin, which seems not too small.
It’s fast to find results, but it’s much slower for others to download your js files. Haha, who should I abandon?
The following code can even have 1 billion entries, and it will still be found quickly, but use the iteration mode to create the array. . . So don’t try it. Just to give you an idea, I will post a JS solution to the Eight Queens problem next time. Haha, the algorithm is amazing