Recursion Flashcards

1
Q

Write function to find factorial of 5?

A
function factorial(num){
 if(num \< 3){
 return num;
 }
 return num \* factorial(num - 1);
}
factorial(2)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Find the fibonacci of 4?

A
function fibonacci(num){
 if(num \<=1){
 return num;
 }
 return fibonacci(num - 1) + fibonacci(num - 2);
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a selection or combination?

A

It is a subset of a set of objects. In the set {a,b,c}, the subset {a,b} is a selection. All the selections for the set {a,b,c} are {a,b}, {a,c}, and {b,c}. order of items in set doesnt matter so {a,b} is same os {b,a}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a permutation?

A

A permutation is an ordered arrangement of a subset of items taken from a set. all the permutations of two items taken from the set {a,b,c} are (a,b),(a,c),(b,a),(b,c),(c,a), (c,b),

How well did you know this?
1
Not at all
2
3
4
5
Perfectly