50 likes | 168 Vues
Join us as we dive into the exciting world of recursion through "The Real Bear Game". This engaging session presents the properties of successful recursive algorithms and challenges participants with the journey of the Three Bears. Learn how to derive new bear counts through the odd/even rules while exploring the captivating Box Stuffing problem. Can you fit teddy bears of various set sizes into a box with a capacity of 27? Enhance your understanding of recursion and algorithmic thinking in this interactive and educational event!
E N D
Recursion: The Real Bear Game March 27, 2006
Outline • Handouts(1) • Perils of JavaSchools • Announcements • Properties of Successful Recursive Algorithms • Three Bears + 1 • Box Stuffing
Successful Recursion • Has to Stop • Reentrant
Three Bears + 1 • X = # of bears • If X is odd, the new number of bears that you have is 3 * X + 1 • If X is even, the new number of bears that you have is X / 2. • For all X, does this sequence always converge to 1 bear?
Box Stuffing • The problem is to exactly (or mostly) fit a box with sets of teddy bears. • If you have bears in sets of 1, 2, 3, 5, 10, 15, and 20, can you fit a box with the capacity of 27?