From 1d22356ce52fc385f4fce906056017fd5e6e3257 Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Tue, 6 Feb 2024 22:04:37 +0000 Subject: [PATCH] upd readmes, rename exercises. --- chapter3/README.md | 10 ++++++++++ chapter4/README.md | 11 ++++------- chapter4/{summation.py => ex4.1.py} | 0 chapter4/{maximum.py => ex4.3.py} | 0 chapter4/{binary.py => ex4.4.py} | 0 5 files changed, 14 insertions(+), 7 deletions(-) create mode 100644 chapter3/README.md rename chapter4/{summation.py => ex4.1.py} (100%) rename chapter4/{maximum.py => ex4.3.py} (100%) rename chapter4/{binary.py => ex4.4.py} (100%) 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