stl algorithm brief

Sorting Algorithm:

sort: the sort of comprehensive strategy,

1. First use sort intro_sort

1.1 intro_sort as quicksort block mode, using the remaining stack rows sort the data block when the depth is larger than the threshold.

After 1.2 after 1.1 intro_sort sorted, substantially most of the data in the ordered state

2. Then a substantially ordered state 1, the final insertion sort, since the data is ordered substantially 1, so insertion sort of actual efficiency is very high, will not be O (n ^ 2)


partial_sort: Local sorting

Underlying implementation of stack rows, the container is a Vector, continuous array

Construction of the heap: the leaf nodes on the filter

Sort: the root node is typically removed, and then change the last leaf node to the root node, and can be filtered off.

Stl but not exactly the same, but start at the root do hollow filtered off, and then the end of the leaf node as the cavity, and then the filter.

This is some doubt, why not just put the leaf nodes with position, and then the next filter based on its value, carried out in one step

Published 140 original articles · won praise 28 · views 180 000 +

Guess you like

Origin blog.csdn.net/qq_16097611/article/details/78891263