Skip to content · ⁨ข้ามไปยังเนื้อหา⁩

Recursion: base case and recursive case · ⁨Recursion: Base case และ Recursive case⁩

English

A function that calls itself

  • Recursion is when a function calls itself to solve a smaller version of the same problem.
  • It needs two parts: a base case that stops, and a recursive case that shrinks the problem.
  • Without a base case, it would call itself forever and crash.
ไทย

ฟังก์ชันที่เรียกตัวเอง

  • Recursion คือเมื่อฟังก์ชันเรียก ตัวเอง เพื่อแก้ปัญหารุ่นย่อยๆ ของปัญหาเดียวกัน
  • ต้องมีสองส่วน: Base case ที่หยุดการทำงาน และ Recursive case ที่ลดขนาดปัญหา
  • หากไม่มีกรณีฐาน มันจะเรียกตัวเองตลอดกาลจนระบบล้มเหลว

Handout · ⁨เอกสารประกอบการเรียน⁩

Log in or create account · ⁨เข้าสู่ระบบหรือสร้างบัญชี⁩

IGCSE, A-Level & AP