MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / leftRotate

Method leftRotate

structure/tree/avl.go:323–339  ·  view source on GitHub ↗
(x *AVLNode[T])

Source from the content-addressed store, hash-verified

321}
322
323func (avl *AVL[T]) leftRotate(x *AVLNode[T]) *AVLNode[T] {
324 y := x.right
325 yl := y.left
326 y.left = x
327 x.right = yl
328
329 if yl != avl._NIL {
330 yl.parent = x
331 }
332
333 y.parent = x.parent
334 x.parent = y
335
336 x.height = avl.height(x)
337 y.height = avl.height(y)
338 return y
339}
340
341func (avl *AVL[T]) rightRotate(x *AVLNode[T]) *AVLNode[T] {
342 y := x.left

Callers 2

pushHelperMethod · 0.95
deleteHelperMethod · 0.95

Calls 1

heightMethod · 0.95

Tested by

no test coverage detected