트리 μ•Œκ³ λ¦¬μ¦˜Advanced

AVL 트리

1962λ…„ Adelson-Velsky와 Landisκ°€ 발λͺ…ν•œ 졜초의 μžκ°€ κ· ν˜• 이진 검색 νŠΈλ¦¬μž…λ‹ˆλ‹€. μ„œλΈŒνŠΈλ¦¬μ˜ 높이 차이λ₯Ό μ΅œλŒ€ 1둜 μœ μ§€ν•˜μ—¬ O(log n) 연산을 보μž₯ν•©λ‹ˆλ‹€. μ‚½μž…/μ‚­μ œ ν›„ μž¬κ· ν˜•μ„ μœ„ν•΄ λ„€ κ°€μ§€ μœ ν˜•μ˜ νšŒμ „(LL, RR, LR, RL)을 μˆ˜ν–‰ν•©λ‹ˆλ‹€. λ°μ΄ν„°λ² μ΄μŠ€, 파일 μ‹œμŠ€ν…œ, 보μž₯된 둜그 연산이 μ€‘μš”ν•œ 곳에 μ‚¬μš©λ©λ‹ˆλ‹€.

#tree#self-balancing#rotation#binary-search-tree

Complexity Analysis

Time (Average)

O(log n)

Expected case performance

Space

O(n)

Memory requirements

Time (Best)

O(log n)

Best case performance

Time (Worst)

O(log n)

Worst case performance

πŸ“š CLRS Reference

Introduction to Algorithmsβ€’Chapter 13β€’Section Notes

Watch rotations maintain balance!

Rotation Types

  • β€’ LL: Right rotation (left-heavy)
  • β€’ RR: Left rotation (right-heavy)
  • β€’ LR: Left-Right rotation
  • β€’ RL: Right-Left rotation
  • β€’ Balance factor: height(left) - height(right)
  • β€’ O(log n) for insert, delete, search
Step: 1 / 0
500ms
SlowFast
Keyboard Shortcuts
Space Play/Pause← β†’ StepR Reset1-4 Speed

Real-time Statistics

Algorithm Performance Metrics

Progress0%
Comparisons
0
Swaps
0
Array Accesses
0
Steps
1/ 0

Algorithm Visualization

Step 1 of 0

Initialize array to begin

Default
Comparing
Swapped
Sorted

Code Execution

Currently executing
Previously executed

Implementation

AVL Tree - Algorithm Vision