|
|
|
@ -1370,16 +1370,16 @@ students.stream()
@@ -1370,16 +1370,16 @@ students.stream()
|
|
|
|
|
|
|
|
|
|
The basic case of recursion is a function calls itself, reducing the size of |
|
|
|
|
the problem at each subsequent call, to progress towards a base case. |
|
|
|
|
|
|
|
|
|
function { |
|
|
|
|
``` |
|
|
|
|
function { |
|
|
|
|
if (base case) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
else (reduction cases) { |
|
|
|
|
return function(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
``` |
|
|
|
|
This has the risk of stack overflows, because each call adds to the callstack. |
|
|
|
|
|
|
|
|
|
Recursion is more elegant for some types of problems, which are naturally |
|
|
|
@ -1435,4 +1435,9 @@ Visualisation Sites:
@@ -1435,4 +1435,9 @@ Visualisation Sites:
|
|
|
|
|
- [sorting.at](http://sorting.at) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Contributing |
|
|
|
|
|
|
|
|
|
Source for this page is available |
|
|
|
|
[here](https://git.topost.net/alistair/csse2002-notes/src/branch/master). |
|
|
|
|
|
|
|
|
|
Contributions are welcome. |
|
|
|
|