I want to find approximate degrees in the ordered list; I know two algorithms
algorithm 1 - Quick selection
Algorithm 2 - In the middle of the middle
I can not use quick selection in my project because it takes O (N ^ 2) in the worst case Have heard about the middle of the intermediaries, but my colleagues say that it takes O (n) with some (continuous) factor It is. Therefore its complexity of time is CN and the constant factor is that compared to the large number of selected elections, I want to know what is the constant factor associated with the intermediate middle? And do not use the pseudo mid of 9 elements in the center of the middle? Or does their algorithm find approximate measurable value in the linear time (n)?
Although I do not hurry to select quickly, because its worst position is not properly displayed Hardly:
Introselect (low for "self-selective selection") is a selection algorithm that is a hybrid of intermediate and quick intermediate hybrids, with rapid average performance and optimum poor-type performance.
Selection of introselect starts with faster selection and only switches to the highest linear algorithm of time if it is repeated repeatedly without adequate progress. Switching is the main technical content of strategy algorithms. Simply restricting the recursive to continuous depth is not good enough, because it will make algorithm switches on all sufficiently large lists. Musa discusses some simple methods:
- Keep track of the list of sizes of processed subdivisions so far. If at any point the repeated calls are made without halving the list size, then for some small positive, switch to the bad-case linear algorithm.
- The sum of the size of all the divisions generated till now. If this is slightly smaller than the continuous list of continuous k, switch to the linear algorithm of the worst case. This yoga is easy to track in a single scalar variable.
In both ways, the depth of the recurrence is ⌈log n⌉ = O (log n) and the total time o (n).
Comments
Post a Comment