Recursion is a process where a function calls itself in order to solve a problem, typically with a base case to stop the function from calling itself indefinitely.
所謂的遞迴,就是函數在未滿某些條件下持續呼叫函數本身以解決問題,當達成基本條件則會停止,以阻止無限呼叫自己
Here's some featurs of recursion
遞迴的特色
A decision tree is a tree-like model used for decision-making, particularly useful in complex or uncertain situations.
It split data into branches on feature values, leading to outcomes or decisions at the leaf nodes.
This model is powerful for both classification and regression tasks in machine learning.
Here's a simple decision tree for example:
Write a function to calculate factorial of the number.
寫個 function 計算出 n!
calculate 8!
所謂的 8! 就是 8x7x6x5x...x1
提示:使用 recursion
Answer:
function getFactorial(number){
if(number===1){
return 1;
}
return number*getFactorial(number-1);
}
getFactorial(8); // 40320
Master Recursion: One-Branch & Two-Branch Techniques
https://youtu.be/LmZGI60c31g?si=ThUXGzcyAp64QNRc
regression
https://web.ntnu.edu.tw/~algo/Regression.html