You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@ This is a repository of toy problems to be solved using recursion and JavaScript
14
14
15
15
> Pseudocode helps you focus on the algorithm instead of getting distracted by syntax.
16
16
17
-
- This repo requires each function call itself recursively and pays no attention to whether inner recursive functions defined and called.
17
+
- This repo requires each function call itself recursively and pays no attention to whether inner recursive functions are defined and called.
18
18
19
19
> While both are valid uses of recursion, there are important lessons to learn by following the method this repo enforces. Defining inner functions and calling them recursively relies on side effects, while following the more pure approach requires an understanding of how values are passed through the call stack.
20
20
@@ -44,10 +44,10 @@ Is it a true definition? Mostly. Recursion is when a function calls itself. A re
44
44
_What does this all mean?_ Let's consider a silly example:
45
45
```sh
46
46
functionstepsToZero(n) {
47
-
if (n === 0) { // base case
47
+
if (!n === 0) { /* base case*/
48
48
console.log('Reached zero');
49
49
return;
50
-
} else { // recursive case
50
+
} else { /* recursive case*/
51
51
console.log(n + ' is not zero');
52
52
return stepsToZero(n-1);
53
53
}
@@ -83,6 +83,6 @@ Recursion isn't unique to any one programming language. As a software engineer,
83
83
84
84
85
85
### Divide and Conquer
86
-
Recursion is often used in _divide and conquer_ algorithms where problems can be divided into similar subproblems and conquered individually. Consider traversing a tree structure. Each branch may have its own "children" branches. And every branch is essentually just another tree which means, as long as child trees are found, we can recurse on each child.
86
+
Recursion is often used in _divide and conquer_ algorithms where problems can be divided into similar subproblems and conquered individually. Consider traversing a tree structure. Each branch may have its own "children" branches. Every branch is essentually just another tree which means, as long as child trees are found, we can recurse on each child.
0 commit comments