Ps8

445 views

Published on

Published in: Technology, Art & Photos
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
445
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Ps8

  1. 1. There once was a little girl named Alyssa P. Hacker.
  2. 2. Her dad was acomputer scientist. He worked with computers all day long.
  3. 3. Alyssa always heardhim talking aboutsomething called“recursion”, so oneday she asked him,“Dad, what does‘recursion’ mean?”“Well,” he said,“Recursion is whenyou define aprocedure in terms ofitself.”“I don’t get it,” saidAlyssa.
  4. 4. “Let me put it this way,”her dad said. “You knowthe story ofCinderella, don’t you?” heasked.“Of course! She’s myfavorite princess!” Alyssasmiled.“Do you remember whathappens at the end?” heasked.“Yeah! The prince findsCinderella and they getmarried and live happilyever after!”
  5. 5. “Right!” he said. “Theprince knows that theshoe will only fitCinderella, but hedoesn’t know who sheis, so he must test allof the girls until hefinds her. Since hedoesn’t know howmany girls thereare, he doesn’t knowhow many times hewill have to try thesame test, so he usedlogic to devise amethod of findingCinderella.
  6. 6. He tries the shoe on agirl, and if the shoefits, they can getmarried and live happilyevery after, but if not, hemust move on to thenext girl and try to findCinderella again bytrying the shoe on her.He can only stop oncehe finds the right girl!What the prince wasdoing was like arecursive procedure.”
  7. 7. “Oh!” said Alyssa. “Ithink I get it now!Recursion is like tryingto solve a problem bytrying the same ideaover and over again ondifferent things until itworks.”“That’s pretty close!”her dad told her. “Ithink you’ll be a greatcomputer scientist oneday!”
  8. 8. (define (Find-Cinderella girls) (if (Shoe-fits? (car girls)) (Live-Happily-Ever-After) (Find-Cinderella (cdr girls))))
  9. 9. Picture Sources:• http://www.free-clipart- pictures.net/free_clipart/kid_clipart/kid_clipart_girl_smiling.gif• http://mylesfish.files.wordpress.com/2009/11/computer-guy-clip- art.png• https://lh3.googleusercontent.com/- eQdxpgeVxcg/TW8BjZKekiI/AAAAAAAACB4/Nt5oyJBed8o/girl- confused-vector.jpg• http://eventservices.disney.go.com/files/400001965139.jpg• http://images2.fanpop.com/image/polls/390000/390297_126765232 6501_full.jpg• http://www.disneyclips.com/imagesnewb3/imageslwrakr01/cn94.gif• http://activerain.com/image_store/uploads/5/6/8/1/9/ar126300265 191865.jpg• http://images1.wikia.nocookie.net/__cb20101009032724/disney/ima ges/6/61/Feb511.gif• http://pegaweb.com/tutorials/open-book-with-pages/5.jpg• http://www.fromoldbooks.org/Geneva/pages/000-Front-Cover/000- Front-Cover-q75-1007x1300.jpg

×