MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / lr_rotation

Function lr_rotation

data_structures/binary_tree/avl_tree.py:126–140  ·  view source on GitHub ↗

r""" A A Br / \ / \ / \ B C LR Br C RR B A / \ --> / \ --> / / \ Bl Br B UB Bl UB C \ /

(node: MyNode)

Source from the content-addressed store, hash-verified

124
125
126def lr_rotation(node: MyNode) -> MyNode:
127 r"""
128 A A Br
129 / \ / \ / \
130 B C LR Br C RR B A
131 / \ --> / \ --> / / \
132 Bl Br B UB Bl UB C
133 \ /
134 UB Bl
135 RR = right_rotation LR = left_rotation
136 """
137 left_child = node.get_left()
138 assert left_child is not None
139 node.set_left(left_rotation(left_child))
140 return right_rotation(node)
141
142
143def rl_rotation(node: MyNode) -> MyNode:

Callers 2

insert_nodeFunction · 0.85
del_nodeFunction · 0.85

Calls 4

left_rotationFunction · 0.85
right_rotationFunction · 0.85
get_leftMethod · 0.80
set_leftMethod · 0.80

Tested by

no test coverage detected