diff --git a/chapter3/README.md b/chapter3/README.md new file mode 100644 index 0000000..efed166 --- /dev/null +++ b/chapter3/README.md @@ -0,0 +1,10 @@ +# Recursion + +Recursive functions must have both: + +- one or more base cases +- a recursive case + +The base cases are required to ensure the recursion stops when meeting a condition + +The recursive case adds functions onto the call stack and completes each one top down. diff --git a/chapter4/README.md b/chapter4/README.md index 37fffe3..dca162d 100644 --- a/chapter4/README.md +++ b/chapter4/README.md @@ -1,12 +1,9 @@ -# Recursion +# Quicksort -Recursive functions must have both: +Similar to the previous recursive function, quicksort uses divide and conquer. -- one or more base cases -- a recursive case +The base case occurs for an array size 0 or 1 (doesn't need to be sorted). -The base cases are required to ensure the recursion stops when meeting a condition - -The recursive case adds functions onto the call stack and completes each one top down. +The recursive case works by partitioning the array around a chosen pivot repeatedly until the base case is met and then combining all sorted sub-arrays. Note. Quicksort should be implemented using a random pivot to ensure average runtimes. diff --git a/chapter4/summation.py b/chapter4/ex4.1.py similarity index 100% rename from chapter4/summation.py rename to chapter4/ex4.1.py diff --git a/chapter4/maximum.py b/chapter4/ex4.3.py similarity index 100% rename from chapter4/maximum.py rename to chapter4/ex4.3.py diff --git a/chapter4/binary.py b/chapter4/ex4.4.py similarity index 100% rename from chapter4/binary.py rename to chapter4/ex4.4.py