Skip to content

Commit

Permalink
Fixed a few typos
Browse files Browse the repository at this point in the history
  • Loading branch information
nbro committed Jan 20, 2017
1 parent 8e0911c commit 19f84de
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
14 changes: 11 additions & 3 deletions ands/algorithms/recursion/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Recursive Algorithms
# Recursion

Algorithms that use recursion that do not fall in any more specific category. For example, the problem "the nth fibonacci number" can be solved using recursion, but it can also be solved more interestingly using dynamic programming, and so you can find those algorithms (including the recursive one) under the folder `dp`.

There are many other algorithms in other repositories, such as in [sorting](../sorting) that use recursion, for example quicksort and merge sort use recursion.
Algorithms that use recursion that do not fall in any more specific category and which are, in my opinion, good and simple examples of recursive algorithms.

There are other recursive algorithms in this project that would also be good examples to show how recursion works, for example [`quick_sort`](../sorting/quick_sort.py), but I thought they would be better examples of other concepts.


## Possibly useful resources

- [https://en.wikipedia.org/wiki/Recursion_(computer_science)](https://en.wikipedia.org/wiki/Recursion_(computer_science))

- [https://www.khanacademy.org/computing/computer-science/algorithms/recursive-algorithms/a/recursion](https://www.khanacademy.org/computing/computer-science/algorithms/recursive-algorithms/a/recursion)
2 changes: 1 addition & 1 deletion ands/algorithms/recursion/factorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def fact_cap_2(num):


def n_choose_k(n, k):
"""Returnså the number of ways of choosing `k` elements,
"""Returns the number of ways of choosing `k` elements,
disregarding their order, from a set of `n` elements."""
if n >= 0 and k >= 0:
if n == k or k == 0:
Expand Down
6 changes: 3 additions & 3 deletions ands/algorithms/recursion/make_decimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def _build_alpha_numeric_alphabet() -> dict:
"""Returns a dictionary whose keys are all nine digits from 0 to 9
and the 26 letters of the English alphabet.
The values of the numbers are the numbers themselves;
the values of the letters are 10 for 'a', 11 for 'b', and so on until 26 for 'z'."""
the values of the letters are 10 for 'a', 11 for 'b', and so on until 36 for 'z'."""
alphabet = {}
for i, char in enumerate(ascii_lowercase):
# Letters of the alphabet start after digit 9.
Expand Down Expand Up @@ -51,7 +51,7 @@ def _make_decimal(n: str, b: int, pos: int) -> int:
2 + 240 + 3584 =
3826
Note in any number `xyz` in any base `b`,
Note: in any number `xyz` in any base `b`,
z is in the "ones" position (has the smaller "value"),
y is in the "tens" position and
x is in the "hundreds" position (has the greatest "value").
Expand All @@ -64,7 +64,7 @@ def _make_decimal(n: str, b: int, pos: int) -> int:


def make_decimal(n: str, base: int) -> int:
"""`n` number in any base in the range [2, 36].
"""`n` is a number in any base in the range [2, 36].
`base` is the base in which `n` is currently represented.
Assumes `n` only contains digits in the range 0..9
Expand Down

0 comments on commit 19f84de

Please sign in to comment.