재귀

더 작은 하위 문제를 해결하기 위해 자기 자신을 호출하는 함수.

Recursion is a programming technique where a function calls itself directly or indirectly. It involves a 'base case' to terminate the process and a 'recursive step' that breaks the problem into a simpler version of itself. It is particularly elegant for solving problems involving trees, fractals, and mathematical sequences.

        graph LR
  Center["재귀"]:::main
  Rel_algorithm["algorithm"]:::related -.-> Center
  click Rel_algorithm "/terms/algorithm"
  Rel_adiabatic_quantum_computation["adiabatic-quantum-computation"]:::related -.-> Center
  click Rel_adiabatic_quantum_computation "/terms/adiabatic-quantum-computation"
  Rel_search_algorithm["search-algorithm"]:::related -.-> Center
  click Rel_search_algorithm "/terms/search-algorithm"
  classDef main fill:#7c3aed,stroke:#8b5cf6,stroke-width:2px,color:white,font-weight:bold,rx:5,ry:5;
  classDef pre fill:#0f172a,stroke:#3b82f6,color:#94a3b8,rx:5,ry:5;
  classDef child fill:#0f172a,stroke:#10b981,color:#94a3b8,rx:5,ry:5;
  classDef related fill:#0f172a,stroke:#8b5cf6,stroke-dasharray: 5 5,color:#94a3b8,rx:5,ry:5;
  linkStyle default stroke:#4b5563,stroke-width:2px;

      

🧠 지식 테스트

1 / 1

🧒 5살도 이해할 수 있게 설명

계단을 세고 싶다고 상상해 보세요. '계단이 몇 개지? 음, 1 더하기 남은 계단 수야'라고 말할 수 있습니다. 계단이 남지 않을 때까지 계속 묻습니다. 그것이 재귀입니다!

🤓 Expert Deep Dive

꼬리 호출 최적화(TCO)는 꼬리 재귀 함수의 스택 증가를 제거합니다. 메모이제이션은 지수 피보나치를 선형으로 변환합니다. 연속 전달 스타일(CPS)은 모든 호출을 꼬리 호출로 만듭니다. Y 결합자는 람다 대수에서 재귀를 가능하게 합니다.

📚 출처