heuristic merge

1. Operation method

When merging two data structures, the elements of the small data structure should be inserted into the large data structure one by one.

2. Time complexity

If the problem has only insertion operations, the total complexity should be O ( n l o gn)

Explanation : Because of each merge, the total size of all data structures is n. If the size of the two data structures is x, y (n≥x≥y) , the time complexity is O(y) , and the size of the data structure will become x +y , in the worst case, the complexity of merging once can only be O (n) , and because it can only merge logn times at most, the total time complexity is O(nlogn) .

Note : If there are not only insert operations, but also split operations, the total complexity is not necessarily O ( n l o gn ) .




Note: If you learned about heuristic merging through this article, please like and leave. Of course, you are also welcome to point out the shortcomings of this article in the discussion area. The author will correct this article in time
. Copyright statement: Please indicate the address for reprinting

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325763400&siteId=291194637