MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / erase

Function erase

data_structures/binary_tree/treap.py:96–106  ·  view source on GitHub ↗

Erase element Split all nodes with values less into left, Split all nodes with values greater into right. Merge left, right

(root: Node | None, value: int)

Source from the content-addressed store, hash-verified

94
95
96def erase(root: Node | None, value: int) -> Node | None:
97 """
98 Erase element
99
100 Split all nodes with values less into left,
101 Split all nodes with values greater into right.
102 Merge left, right
103 """
104 left, right = split(root, value - 1)
105 _, right = split(right, value)
106 return merge(left, right)
107
108
109def inorder(root: Node | None) -> None:

Callers 1

interact_treapFunction · 0.85

Calls 2

splitFunction · 0.70
mergeFunction · 0.70

Tested by

no test coverage detected