Lecture 21, CS 302-7 and 8, March 9
i. Why? Some people still havent taken it
i. 10pm today-pairs must be registered
i. But it is good to know
Recursion:
Definition - "Recursion".
i. Elegant/simple/concise solutions to complicated problems sometimes (just about) the only solution
ii. Also one of the most confusing
ii. Search recursion in google
i. Recursive case
1. Case that repeats occurs most of the time
2. Calls itself
ii. Base case
1. Case that terminates does not call itself
2. Often something like when length is 0, when value is 0, etc
i. Dont do something until you have to.
ii. In Java keep doing things on the right side of the equation as long as possible
i.
Factorials.java
i. Note not quite the same, but similar sort of idea.
ii. Pictures containing themselves (like methods calling selves)
iii. http://www.youtube.com/watch?v=QsMvoui5WlQ
1. Sierpinski triangle confined recursion of triangles
iv. Droste effect
1. http://en.wikipedia.org/wiki/File:Droste.jpg
2. Picture contains itself
3. http://www.youtube.com/watch?v=hKFhI9hdteE
a. MC Escher
i. Definition all possible orders of the letters in the word
ii. Idea pick a letter, stick it in front. You have n-1 letters left. Pick a letter from that, stick it in front. Etc. Do this for each possible selection.
iii. Anagrams.java