algorithm - Order statistic on intervals -
Looking at an array of numbers, output Can these questions be answered in the polygarydiumic time ( Edit : This can be solved using a continuous tree tree Yes, these questions can be answered in polylog timings. Segment tree is deeply prefixed array by forming it with To answer a query, the split category is given (maximum 2 * in log (n) suburals) For example, Category a [0], a [1], ..., a [ N-1] , we get this type of query:
k - the largest number in the range
a [i], a [i] + 1], ..., a [J]
n ) in the query? If not, is it possible for the average result and still can get a good refined complexity?
log (n) Therefore, the leaf nodes are similar to the source array, in the next-depth nodes, the 2-element sub-array is sorted In the next level, there are 4-element arrays created by mixing those two-element aerozes, in other words, sort the merge, but each merge phase has the result of a different array. Here is an example:
Route: | 1 2 3 5 5 7 8 9 1 2 5 8 3 5 7 9 | 1 5 | 2 8 | 7 9. 3 5 Source: | 5 | 1 | 2 | 8 | 7 | 9 | 5 | 3 |
[0, 4] should be divided into
[0, 3] and
[4] , which gives two sorted arrays
[1 2 5 8] And
[7] . Now the problem has been simplified to find the K-element in many ranks arrays. The easiest way to solve this is by binary search nested: first select binary search to select some candidate elements from each array starting from the first; Then use the binary search in other (small) arrays to determine the rank of this candidate element. It allows to get the key elements in time (log (n) ^ 4) possibly some optimization (such as frictional cascading) or some other algorithm can do it faster ...
Comments
Post a Comment