I'm not sure how to navigate the tree structure below so that the nodes are always in ascending order. The heapifying array [9 8 7 6 5 4 3 2 1 0]leads to an array [0 1 3 2 5 4 7 9 6 8]that seems to fit this view:
[9 8 7 6 5 4 3 2 1 0]
[0 1 3 2 5 4 7 9 6 8]
The desire to keep the array as it is (because I want to do efficient inserts later), how can I efficiently move it in ascending order? (This is a site visit in that order [0 1 2 3 4 5 6 7 8 9])
[0 1 2 3 4 5 6 7 8 9]
. - - , .
nofollow " > self-balancing ( BST) :
(BST)... node, :node node.node , node...
(BST)... node, :
BST ( ), .
BST O (log n) O (n).
, - O (1) O (n log n), - , , BST, .
, , ( , , , , , , , - ).
- , , , , .. - , , - , .
, , .
, :
O (n log n) O (n) ( , BST O (log n)), .
, BST. @Dukeling , BST , - . , O (1) .
, .
O (n log n). - O (n).
If you don’t need to completely move around, you can stop at any time and “fix” the array by performing the O (n) heapify operation. See pseudo code here , for example.
Source: https://habr.com/ru/post/1530033/More articles:Why does Task implement IAsyncResult, but does not contain an AsyncWaitHandle member? - c #async indexer in c # - c #Добавить ListItem в папку списка с помощью Rest-Api - javascriptColdFusion 9, JSON and jQuery EasyUI - jsonCannot start TopShelf remotely using psexec - psexecMVC ASP.NET minify Views.cshtml - asp.net-mvcPaste current entry into BBDB - emacsEmbedding Python 3.3 in C ++ from the zipped standard library in Windows XP - c ++Approximate comparison of two event lists (with duration) - algorithmPython max () does not accept keyword arguments - pythonAll Articles