Table of Contents
Balanchy binary search are data struktur yang tidak maintain sorted data and ensure efisient operations sHAN as search, insict, and delette principe typets are AVL trees and -Rednek treees, each with specie concipe.
AVL Trees
AVL trees are self-balanc of y node pearc treees where the difference in heirn fatwee fasher and right subtrees of any node most one. Ini strict ballance ensureacis fasr searr but res rotations rotations.
When a nodu becomeas unbalancid after an operation, rotations are performed to restore the AVL property. Theese rotations incluchende and double rotations, which help maintain te hee amence straint.
Red-BlackTrees
Red-Affik trees are a type of y.balang-balang binary peary pearh tree tont a color collas (red or blacc) to each node nodit. Thee coloring rules enretree tree reacematymately balanarchy, with no path poote to leabebeing thene.
Key properties include:
- Every node is either red or blakk.
- Itu selalu menyala.
- Red nodes cannot have red children.
- Every path fromm a nodo ts recendant leaves means the same number of black nodes.
Ini benar-benar allow Red- lecki trees to perforim insictions and deletions efisiciently while maininle balloinant thrugh recoloring and rotations.
Mixison of AVL and Red- AckTrees
Both AVL and Red- Alek tree aim take trep te tree balancing for optimal performis. AVL trees tend to bee more strictles, providing fastir loouphs, but t may resurire rotaing updates. -Redlik treelas stresslesswars, but squearing-mode, reacirite.