Possible to update nodes key in a red-black tree, without removing and inserting?

前端 未结 1 1553
说谎
说谎 2021-01-15 05:11

Typically changes to a key in a red-black tree need to be performed by removing, then re-inserting the node.

Is it possible to performs key updates to a node in a re

相关标签:
1条回答
  • 2021-01-15 05:34

    Implement update with [search if required +] delete + insert

    1 - delete the key O(log n)
    2 - insert a new node with the new key O(log n)
    Even if you search for a key first, it's O(log n).

    See this page for more details on RBT.

    0 讨论(0)
提交回复
热议问题