Created
October 9, 2014 04:10
-
-
Save lizlongnc/fb94219bfb8bffbf7810 to your computer and use it in GitHub Desktop.
JS Recursion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Recursion - when a function calls itself. | |
Discovered with LISP around 1958. | |
A great example of recursion is the quicksort | |
algorithm: | |
1. use quicksort to divide the array into two groups, low and high | |
if alpha, put all items that begin with a-m into 1st group and the remaining in 2nd group | |
if numbers, determine the mid-point and put lower nums in 1st group and the remaining in 2nd group unless this type of dividing would result in one group being much larger than the other, if so, adj mid-point | |
2. call quicksort again on each group containing more than one element. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment