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

Function left_rotation

data_structures/binary_tree/avl_tree.py:110–123  ·  view source on GitHub ↗

a mirror symmetry rotation of the left_rotation

(node: MyNode)

Source from the content-addressed store, hash-verified

108
109
110def left_rotation(node: MyNode) -> MyNode:
111 """
112 a mirror symmetry rotation of the left_rotation
113 """
114 print("right rotation node:", node.get_data())
115 ret = node.get_right()
116 assert ret is not None
117 node.set_right(ret.get_left())
118 ret.set_left(node)
119 h1 = my_max(get_height(node.get_right()), get_height(node.get_left())) + 1
120 node.set_height(h1)
121 h2 = my_max(get_height(ret.get_right()), get_height(ret.get_left())) + 1
122 ret.set_height(h2)
123 return ret
124
125
126def lr_rotation(node: MyNode) -> MyNode:

Callers 4

lr_rotationFunction · 0.85
rl_rotationFunction · 0.85
insert_nodeFunction · 0.85
del_nodeFunction · 0.85

Calls 8

my_maxFunction · 0.85
get_heightFunction · 0.85
get_dataMethod · 0.80
get_rightMethod · 0.80
set_rightMethod · 0.80
get_leftMethod · 0.80
set_leftMethod · 0.80
set_heightMethod · 0.80

Tested by

no test coverage detected