170 likes | 469 Views
TO. Puzzles. ALGORITHMS. Brian Thompson bthom@cs.rutgers.edu. Why Puzzles?. Learning algorithms may be intimidating for students who are new to computer science Puzzles are more familiar and are frequently seen as challenging and fun
E N D
TO Puzzles ALGORITHMS Brian Thompson bthom@cs.rutgers.edu CS4HS Teacher Workshop @ Rutgers University
Why Puzzles? • Learning algorithms may be intimidating for students who are new to computer science • Puzzles are more familiar and are frequently seen as challenging and fun • Strategy: use puzzles to introduce computer science concepts, algorithms, and data structures CS4HS Teacher Workshop @ Rutgers University
Fair Cake-Splitting CS4HS Teacher Workshop @ Rutgers University
Fair Cake-Splitting • Materials: worksheet, mini-cakes (be aware of allergies), knives, plates/napkins, Java applet: http://pidancer.com/Projects/CakeCutting/ • Puzzle: Split a cake amongst several people, so each is guaranteed to get his/her fair share • Goal: Introduce the idea of an algorithm, demonstrate that algorithms can be used to solve everyday problems CS4HS Teacher Workshop @ Rutgers University
Fair Cake-Splitting • Hand out the worksheet, introduce the problem out loud. • Have students form groups of 3, discuss the 2-person cake-splitting scenario in groups, raise hand if they have questions. • After 5 minutes, choose a group to present their solution (and why it is fair for both participants). • While groups discuss 3-person cake-splitting, hand out a mini-cake with knife and plate/napkin per group to try out their solution. • After 5 minutes, ask for volunteers to present their solution. As a class, analyze whether the solution is fair. Encourage discussion. • Present the “SAY WHEN” n-person fair cake-splitting algorithm. Discuss/prove why it is fair. • Test out the “SAY WHEN” algorithm with the whole class using the Java applet here: http://pidancer.com/Projects/CakeCutting/. CS4HS Teacher Workshop @ Rutgers University
Tower of Hanoi CS4HS Teacher Workshop @ Rutgers University
Tower of Hanoi • Materials: Tower of Hanoi game, or make one yourself by bringing 4 stackable items of increasing size • Puzzle: Transfer a stack of disks (or objects) from one pile to another, following two rules:(1) can only move one disk at a time(2) can’t place any disk on top of a smaller disk • Goal: Introduce the (related) concepts of recursion and induction; problem-solving strategy of approaching a complex problem by first solving a simpler problem and then generalizing CS4HS Teacher Workshop @ Rutgers University
Mazes CS4HS Teacher Workshop @ Rutgers University
Mazes • Materials: Worksheet with a maze, should be challenging enough that students will not see the solution immediately • Puzzle: Design a general procedure to solve mazes that will work no matter how big or tricky the maze is • Goal: Can be used to teach back-tracking, binary trees, depth-first search CS4HS Teacher Workshop @ Rutgers University
The Calendar Game CS4HS Teacher Workshop @ Rutgers University
The Calendar Game • Materials: Calendar (handout or projector), pen or pencil, and scratch paper • Puzzle: The Calendar Game, a 2-person turn-based game played on a standard calendar • Goal: Learn how computers play games by thinking about how clever people play games; introduce the concepts of “winning positions” and “losing positions”; show how a different representation can make a problem easier CS4HS Teacher Workshop @ Rutgers University
The Calendar Game • Start at January 1 • Alternate turns doing one of the following: • Jump to a later month, same day(e.g. January 1 August 1) • Jump to a later day, same month(e.g. January 1 January 12) • Can only jump forward in time • Must stay in the same year • Whoever ends up on December 31 wins CS4HS Teacher Workshop @ Rutgers University
The Calendar Game Start Winner! CS4HS Teacher Workshop @ Rutgers University
The Calendar Game • Explain the rules of the game • Play an example game with a student to demonstrate and make sure the rules are clear • Students pair up and play against each other; go around and clarify rules if necessary • After a few minutes, ask for volunteers to present their strategy; encourage discussion • Present the analysis on the following slides CS4HS Teacher Workshop @ Rutgers University
The Calendar Game • Let’s represent the calendar a different way • Work backwards: What happens if your opponent moves to Nov. 30? Start Jan Feb Mar Apr May Jun Jul Aug Sept Oct Nov Dec Winner! CS4HS Teacher Workshop @ Rutgers University
The Calendar Game • Discuss why the dark blue squares are “winning positions” • If both players are clever, who wins? What is the winning first move? Start Jan Feb Mar Apr May Jun Jul Aug Sept Oct Nov Dec Winner! CS4HS Teacher Workshop @ Rutgers University
Thank You! Brian Thompson bthom@cs.rutgers.edu CS4HS Teacher Workshop @ Rutgers University