Box sort

xiaoxiao2021-03-05  31

// Complex is N Rangevoid Binsort (Chain & x, Int Ran & X.Length (); node x; chain * bin; bin = new chain [Range 1]; // Assign for for each box for (int i = 1; i <= len; i ) {x.delete (1, x); bin [x.score] .insert (0, x);} // Collect each element in the box (int J = Range; J> = 0; j -) {while (! Bin [j] .isempty ()) {bin [j] .delete (1, x); X.insert (0, x);}} delete [] bin;}

/ / The box sort can be extended to the base sort: // Assume that 10 integers between ranges 0 to 999 are sorted. The tank sorting of the lowest (0 ~ 9) can be performed first, and then the second bit and the third bit are sequentially sorted in turn.

Ref: << Data Structure, Algorithm & Applications >> P113 ~ 117

转载请注明原文地址:https://www.9cbs.com/read-32243.html

New Post(0)