Tuesday, November 15, 2011

Recursion

So first, here's the program whose stack runneth over:

Then we added a counter so we could see how far down the rabbit hole goes:

And then limited it so that it wouldn't overflow anymore:

(Of course in recitation these were all named Foo.java)

And then here's a drawing thingy:

Which uses Turtle.java

And then here's the one that draws the Sierpinski triangle:

(Oh yeah and check out this comic. The author says he thought of it while trying to write a program to draw a Sierpinski triangle and he kept getting a StackOverflowError. WHAT WAS HE DOING WRONG?)

There will be no recitation Thanskgiving week. I hope everyone has a wonderful Thanksgiving and I will see you in two weeks.

No comments:

Post a Comment