Algorithms. How data is processed. Popescu

Similar documents
Slice apples into pan. Sprinkle with sugar and cinnamon in layers. Add water. Mix sugar, butter and flour. Spread on top and bake.

2011 Apple Butter Frolic Baking Contest Recipes

The Father Hecker Cookbook

Apple Butter Frolic Apple Baking Contest Recipes

Crawfish Stew... 2 Spiced Fig Cake... 2 Fig Filling... 3

2011 Holiday Dishes. From The RiceSelect Kitchen

I thought I d share what we ll be having at our table this holiday season. I SET MY GOAL for the entire cost of the

Krazy Kitchen: Fall Foods

Across the Fence Apple Recipes October 2018

LAMB AND SAUSAGE PIE. 53. Copyright 2011 MobileHomeGourmet.com, all rights reserved.

Athena Calderone s Butterscotch Pots De Crème with Salted Caramel Tahini Sauce and Toasted Kasha Makes 6 Servings For the Pots De Crème

Pies. Up Next: Civil War Cooking January/February, 2013 date TBA. Notes. On the web:

Pie Making and Decorating Workshop

APPLE HAND PIES Copyright 2012 The Mobile Home Gourmet, MobileHomeGourmet.com, all rights reserved.

Baked Fruit and Cinnamon Oatmeal

INSTRUCTIONS & RECIPES

Mini Cane Recreational Sports Camp 2015 Cook Book

Oven Safe up to 428 F/220 C. Microwave Safe. Dishwasher Safe. Refrigerator Safe. Freezer Safe. *Features Limited Lifetime Warranty.

CUSTARD PIE. The Step By Step guide begins on the following page.

Braces-Friendly Halloween Recipes

KINGS COUNTY 4-H FOOD OLYMPICS Recipes

CROSSROADS BELLEVUE FARMERS MARKET APPLIE PIE CONTEST 2013 WINNER 1 ST Prize Best Filling & 1 st Prize Judges Choice Ann Hasty

The following dishes are featured in my novel, Carissima.

T H E B A K E B O O K 1

Apple Cinnamon Honey Cake

Delicious recipes for your Fourth of July celebrations featuring one of America s favorite fruits - cherries.

SAVOR THE MYSTERY RECIPE BOOK

Colorful Candy bar Cookies Recipe

"Brown Bag" French Apple Pie

Raspberry Cobbler. Ingredients: Steps: Layla Godfrey. Junior. Fruit Cobbler w/ Homemade Crust. Armstrong County

PEEPS apple yogurt parfait

Using Honey in the Kitchen

Here is this week s menu: Creamy Italian Pasta with Green Salad / Copycat Chili s Molten Lava Cake

North Carolina Peanut Growers Association PB&J Contest Thursday, October 13, 2016

Algorithmic Thinking. Alison Pamment. On behalf of the course team (STFC/NERC:CEDA, NERC:NCAS, NERC:NCEO)

Apple Butter. Thanksgiving Recipes

Bittersweet Chocolate Roulade Yule Log

Peanut Butter Snickerdoodle Tart with Cinnamon Peanut Crust

PickYourOwn.org. Where you can find a pick-your-own farm near you! Peach-Blueberry Pie!

OATMEAL CREAM PIES SALTED CHOCOLATE CHIP COOKIES CHOCOLATE MINT BROWNIES

SOUR CREAM APPLE PIE Copyright 2017 The Mobile Home Gourmet, MobileHomeGourmet.com, all rights reserved.

FAMILY HERITAGE(TM) HOME TOWN GINGERBREAD MOLD INSTRUCTIONS

Smoked Salmon on Irish Soda Bread with Chive Butter Recipe courtesy Dan Smith and Steve McDonagh

Apple Cranberry Crumble

T. oil-mix with rotary beater or in blender. Repeat cooking method per above.

PickYourOwn.org. Where you can find a pick-your-own farm near you!

Cherry Bomb Cookies 1 box cherry cake mix 1 egg 2 cup Cool Whip, thawed

New Mexico 4-H Pastry & Pies Supplement

CARAMEL APPLE CAKE CARAMEL APPLE CAKE

Arrange the bacon in a single layer on a baking sheet. Bake at 350 deg. For minutes or until brown and crisp; drain on paper towels.

Recipes from Saving Amelie

PASTA. Cooking with USE WITH MODEL#GPM500

Sweets & Goodies Recipes: Jack-O'-Lantern Cake Serves: 36

Spring Menu (Dinner For 8)

Like a cinnamon-sugar doughnut in muffin form. You ve been warned.

Thanksgiving with Chef Michael Chiarello

MOUSSAKA Copyright 2014 The Mobile Home Gourmet, MobileHomeGourmet.com, all rights reserved.

PITA PRO FLAT BREAD. Recipes USE WITH MODEL GBM3400

Mild Salsa: Food processor. Ingredients: Ingredients

OCTOBER 2014 RECIPES

PREP TIME 20 minutes MAKES servings

Air-Fried Herbed Roast Beef and Potatoes

MEMBER-EXCLUSIVE. recipes TOP 20 FESTIVE APPETIZERS & DESSERTS FROM

BLUEBERRY PIE BLUEBERRY BUCKLE. 1 egg 2 cups flour

MAKE AHEAD MASHED POTATOES

Carole. Pat B, Collette

15 Classic DESSERTS. PAGEs 5 6. doughnut recipes

BLUEBERRY BLOW OUT 2017

Ingredients. 4.5 lbs. apples (Rome, Jonathan, or Granny Smith) (recommended) Sugar Flour Cinnamon Butter Salt Nutmeg Betty Crocker pie mix

ALL PORK MEALS PLAN JANUARY Table of Contents. Recipes

Set a cheery table that will counter winter s typical grey skies and foster a mood of optimism.

Cinnamon Rolls with a Maple Cream Cheese Frosting

Ultimate Christmas COOKIE CHALLENGE. Our Most Popular Christmas Cookies from

Dolmades (stuffed grape leaves)

Weekly Meal Planner ( ) Day One: Slow Cooked Pork Chops

A small collection of favorite snacks from the Anthony house.

How To Make The Perfect Pie Crust

TABLE OF. Blackberry Grape Crisp Brioche and Grape Bread Pudding Mini-Pavlovas with Lemon Cream and Grapes... 6

All Time Favorite Christmas Cookies.

Concepts/Skills. Materials

BEST OF HOLIDAY HERSHEY S KISSES conical figure is used under license

NEBRASKA. Family Magazine 15 BEST CHRISTMAS COOKIES. IN NEBRAsKA

the Community Diabetes Event cook

Microwave Directions

Intro To Water Bath Canning Applesauce

Sloppy Joe Casserole Serves 4 to 6

PIES. Follow method used for Banana Cream Pie above, mixing coconut into pudding at the end.


MEMBER-EXCLUSIVE COLLECTION 2015 & / OF GENERAL MILLS 2015 & / OF GENERAL MILLS

COLD BREW COFFEE MAKER RECIPES

Cheddar Melt Burgers. SERVES: 4 TEMPERATURE: 370º F COOKING TIME: 16 to 20 minutes

A FAMILY TRADITION ALL NATURAL PRODUCT TAP

Beef & Noodle Stir-Fry. Cheesy BBQ Chicken

Across the Fence Apple Recipes September 2014

Swiss Chard with Raisins and Almonds Recipe from Epicurious.com

COLONIAL EASY COOKIES

Care & Cleaning Instructions:

Fruits of the spirit tea bible study

Recipes from the Tubby Olive

THIS WEEK'S MENU: DAY 2 DAY 1 DAY 3 DAY 5 DAY 4 DAY 7 DAY 6 STANDARD PLAN One Pan Chicken Sausage and Vegetables

Transcription:

Algorithms How data is processed Popescu 2012 1

Algorithm definitions Effective method expressed as a finite list of well-defined instructions Google A set of rules to be followed in calculations or other problem-solving operations, especially by a computer Wikipedia A step-by-step procedure for solving a problem or accomplishing some end especially by a computer M Webster 2

Algorithm specification Plain English (prose) 3

Ingredients: Pastry for 2 crusts (recipe below) 8 cups sliced, peeled assorted baking apples - about 3 lbs. (Granny Smith, Cortland, Jonathan) 2 Tablespoons lemon juice 3/4 cup white sugar 1/4 cup brown sugar 1/4 cup all-purpose flour 1 teaspoon ground cinnamon 1/4 teaspoon ground nutmeg 2 Tablespoons butter 1 egg yolk 1 Tablespoon milk Directions: 1. In a large bowl, toss the sliced apples with lemon juice. 2. Combine sugars, flour, cinnamon and nutmeg; add to apples and toss well to coat. 3. Fill pastry lined 9 inch pie pan with apple mixture. Dot with butter. 4. Place second crust on top of pie filling, cut slits in top of crust to vent. Seal the edges of the crust with a fork or by hand. 5. In a small bowl, beat the egg yolk and milk. Brush mixture over top crust. 6. Bake at 425 degrees F for 15 minutes. 7. Reduce heat to 350 degrees F and bake 40-45 minutes more or until crust is golden and filling is bubbly. Apple pie algorithm www.momswhothink.com 4

Ingredients: Pastry for 2 crusts (recipe below) 8 cups sliced, peeled assorted baking apples - about 3 lbs. (Granny Smith, Cortland, Jonathan) 2 Tablespoons lemon juice 3/4 cup white sugar 1/4 cup brown sugar 1/4 cup all-purpose flour 1 teaspoon ground cinnamon 1/4 teaspoon ground nutmeg 2 Tablespoons butter 1 egg yolk Input 1 Tablespoon milk Directions: 1. In a large bowl, toss the sliced apples with lemon juice. 2. Combine sugars, flour, cinnamon and nutmeg; add to apples and toss well to coat. 3. Fill pastry lined 9 inch pie pan with apple mixture. Dot with butter. 4. Place second crust on top of pie filling, cut slits in top of crust to vent. Seal the edges of the crust with a fork or by hand. 5. In a small bowl, beat the egg yolk and milk. Brush mixture over top crust. 6. Bake at 425 degrees F for 15 minutes. 7. Reduce heat to 350 degrees F and bake 40-45 minutes more or until crust is golden and filling is bubbly. Apple pie algorithm www.momswhothink.com 5

Ingredients: Pastry for 2 crusts (recipe below) 8 cups sliced, peeled assorted baking apples - about 3 lbs. (Granny Smith, Cortland, Jonathan) 2 Tablespoons lemon juice 3/4 cup white sugar 1/4 cup brown sugar 1/4 cup all-purpose flour 1 teaspoon ground cinnamon 1/4 teaspoon ground nutmeg 2 Tablespoons butter 1 egg yolk 1 Tablespoon milk Directions: 1. In a large bowl, toss the sliced apples with lemon juice. 2. Combine sugars, flour, cinnamon and nutmeg; add to apples and toss well to coat. 3. Fill pastry lined 9 inch pie pan with apple mixture. Dot with butter. 4. Place second crust on top of pie filling, cut slits in top of crust to vent. Seal the edges of the crust with a fork or by hand. 5. In a small bowl, beat the egg yolk and milk. Brush mixture over top crust. 6. Bake at 425 degrees F for 15 minutes. 7. Reduce heat to 350 degrees F and bake 40-45 minutes more or until crust is golden and filling is bubbly. Apple pie algorithm Output www.momswhothink.com 6

Ingredients: Pastry for 2 crusts (recipe below) 8 cups sliced, peeled assorted baking apples - about 3 lbs. (Granny Smith, Cortland, Jonathan) 2 Tablespoons lemon juice 3/4 cup white sugar 1/4 cup brown sugar 1/4 cup all-purpose flour 1 teaspoon ground cinnamon 1/4 teaspoon ground nutmeg 2 Tablespoons butter 1 egg yolk 1 Tablespoon milk Directions: 1. In a large bowl, toss the sliced apples with lemon juice. 2. Combine sugars, flour, cinnamon and nutmeg; add to apples and toss well to coat. 3. Fill pastry lined 9 inch pie pan with apple mixture. Dot with butter. 4. Place second crust on top of pie filling, cut slits in top of crust to vent. Seal the edges of the crust with a fork or by hand. 5. In a small bowl, beat the egg yolk and milk. Brush mixture over top crust. 6. Bake at 425 degrees F for 15 minutes. 7. Reduce heat to 350 degrees F and bake 40-45 minutes more or until crust is golden and filling is bubbly. Apple pie algorithm www.momswhothink.com Finite number of well defined instructions 7

Ingredients: Pastry for 2 crusts (recipe below) 8 cups sliced, peeled assorted baking apples - about 3 lbs. (Granny Smith, Cortland, Jonathan) 2 Tablespoons lemon juice 3/4 cup white sugar 1/4 cup brown sugar 1/4 cup all-purpose flour 1 teaspoon ground cinnamon 1/4 teaspoon ground nutmeg 2 Tablespoons butter 1 egg yolk 1 Tablespoon milk Directions: 1. In a large bowl, toss the sliced apples with lemon juice. 2. Combine sugars, flour, cinnamon and nutmeg; add to apples and toss well to coat. 3. Fill pastry lined 9 inch pie pan with apple mixture. Dot with butter. 4. Place second crust on top of pie filling, cut slits in top of crust to vent. Seal the edges of the crust with a fork or by hand. 5. In a small bowl, beat the egg yolk and milk. Brush mixture over top crust. 6. Bake at 425 degrees F for 15 minutes. 7. Reduce heat to 350 degrees F and bake 40-45 minutes more or until crust is golden and filling is bubbly. Apple pie algorithm www.momswhothink.com Instructions for repetitive actions 8

Ingredients: Pastry for 2 crusts (recipe below) 8 cups sliced, peeled assorted baking apples - about 3 lbs. (Granny Smith, Cortland, Jonathan) 2 Tablespoons lemon juice 3/4 cup white sugar 1/4 cup brown sugar 1/4 cup all-purpose flour 1 teaspoon ground cinnamon 1/4 teaspoon ground nutmeg 2 Tablespoons butter 1 egg yolk 1 Tablespoon milk Directions: 1. In a large bowl, toss the sliced apples with lemon juice. 2. Combine sugars, flour, cinnamon and nutmeg; add to apples and toss well to coat. 3. Fill pastry lined 9 inch pie pan with apple mixture. Dot with butter. 4. Place second crust on top of pie filling, cut slits in top of crust to vent. Seal the edges of the crust with a fork or by hand. 5. In a small bowl, beat the egg yolk and milk. Brush mixture over top crust. 6. Bake at 425 degrees F for 15 minutes. 7. Reduce heat to 350 degrees F and bake 40-45 minutes more or until crust is golden and filling is bubbly. Apple pie algorithm www.momswhothink.com Instructions for (implicitly) repetitive actions 9

Ingredients: Pastry for 2 crusts (recipe below) 8 cups sliced, peeled assorted baking apples - about 3 lbs. (Granny Smith, Cortland, Jonathan) 2 Tablespoons lemon juice 3/4 cup white sugar 1/4 cup brown sugar 1/4 cup all-purpose flour 1 teaspoon ground cinnamon 1/4 teaspoon ground nutmeg 2 Tablespoons butter 1 egg yolk 1 Tablespoon milk Directions: 1. In a large bowl, toss the sliced apples with lemon juice. 2. Combine sugars, flour, cinnamon and nutmeg; add to apples and toss well to coat. 3. Fill pastry lined 9 inch pie pan with apple mixture. Dot with butter. 4. Place second crust on top of pie filling, cut slits in top of crust to vent. Seal the edges of the crust with a fork or by hand. 5. In a small bowl, beat the egg yolk and milk. Brush mixture over top crust. 6. Bake at 425 degrees F for 15 minutes. 7. Reduce heat to 350 degrees F and bake 40-45 minutes more or until crust is golden and filling is bubbly. Apple pie algorithm www.momswhothink.com Logical expressions 10

Ingredients: Pastry for 2 crusts (recipe below) 8 cups sliced, peeled assorted baking apples - about 3 lbs. (Granny Smith, Cortland, Jonathan) 2 Tablespoons lemon juice 3/4 cup white sugar 1/4 cup brown sugar 1/4 cup all-purpose flour 1 teaspoon ground cinnamon 1/4 teaspoon ground nutmeg 2 Tablespoons butter 1 egg yolk 1 Tablespoon milk Directions: 1. In a large bowl, toss the sliced apples with lemon juice. 2. Combine sugars, flour, cinnamon and nutmeg; add to apples and toss well to coat. 3. Fill pastry lined 9 inch pie pan with apple mixture. Dot with butter. 4. Place second crust on top of pie filling, cut slits in top of crust to vent. Seal the edges of the crust with a fork or by hand. 5. In a small bowl, beat the egg yolk and milk. Brush mixture over top crust. 6. Bake at 425 degrees F for 15 minutes. 7. Reduce heat to 350 degrees F and bake 40-45 minutes more or until crust is golden and filling is bubbly. Apple pie algorithm www.momswhothink.com Use of sub-algorithms 11

Flaky Pastry Pie Crust Recipe Makes two 9-inch pie crusts Ingredients: 2 1/2 cups all-purpose flour 1/2 teaspoon salt 1 cup butter, chilled and diced 1/2 cup ice water Directions: 1. Combine the flour and salt in a large bowl. 2. Cut in the butter until the mixture resembles coarse crumbs. 3. Stir in the ice water, a Tablespoon at a time, until the crust mixture forms a ball. 4. Wrap dough in plastic wrap and refrigerate for 4 hours or overnight. 5. Sprinkle flour onto rolling surface. Roll dough out, then divide in half. Roll each half to fit a 9-inch pie plate. 6. Place crust in pie plate, pressing evenly into the bottom and sides. Crust sub-algorithm - Another mechanism for implementing abstraction - First one: compound data structures - Instructions for making crust separate from instructions for making apple pie - If you buy crust, don t need to know how you can make it - You can make apple pie with different types of crust, no changes to apple pie instructions needed - You can use same crust algorithm for making other dishes (meat pockets) - If you don t like how the crust tastes, you change the crust recipe, not the entire apple pie recipe 12

Ingredients: Pastry for 2 crusts (recipe below) 8 cups sliced, peeled assorted baking apples - about 3 lbs. (Granny Smith, Cortland, Jonathan) 2 Tablespoons lemon juice 3/4 cup white sugar 1/4 cup brown sugar 1/4 cup all-purpose flour 1 teaspoon ground cinnamon 1/4 teaspoon ground nutmeg 2 Tablespoons butter 1 egg yolk 1 Tablespoon milk Directions: 1. In a large bowl, toss the sliced apples with lemon juice. 2. Combine sugars, flour, cinnamon and nutmeg; add to apples and toss well to coat. 3. Fill pastry lined 9 inch pie pan with apple mixture. Dot with butter. 4. Place second crust on top of pie filling, cut slits in top of crust to vent. Seal the edges of the crust with a fork or by hand. 5. In a small bowl, beat the egg yolk and milk. Brush mixture over top crust. 6. Bake at 425 degrees F for 15 minutes. 7. Reduce heat to 350 degrees F and bake 40-45 minutes more or until crust is golden and filling is bubbly. Apple pie algorithm www.momswhothink.com Generality - Multiple apple types - Any brand flour - Any oven that can bake at 425 13

Algorithm specification Plain English (prose) Sequence of images 14

Billy bookcase assembly 15

Output 16

General rules These are the tools you need Don t work alone, work with someone else Don t work on a hard surface or else you ll damage the corners, work on a soft surface like a carpet If after reading instruction booklet you have questions call IKEA 17

Input 16 pegs, 12 long screws, 18

Step-by-step instructions Instruction 1 Instruction 2 19

Step-by-step instructions Instruction 1 Instruction 2 Instruction 14 Last one, done! 20

iclicker questions What does the image most likely mean? A. Do not allow children to climb on the bookcase as it might tip over. B. Children can climb on the bookcase safely as it ll never tip over. C. Place the bookcase in a spot where it does not case a shadow (shown by dotted line). D. Never place the bookcase close to a corner. E. Hard to say, it s probably Swedish 21

Algorithm specification Plain English (prose) Sequence of images Video sequence E.g. cooking videos 22

Algorithm specification Plain English (prose) Sequence of images Video sequence Hybrid E.g. text and images 23

24

Algorithm building blocks Input Instructions Sub-algorithms Make crust according to instructions below Get to I-65 according to instructions below. Mount bracket according to instructions on page 3. Repetition For For each of the four corners, attach one long screw Mix for 15 minutes While While not golden brown bake Until Until golden brown Tap in until flush with surface Stay on I-65 until Merrillville Conditionals If then do this, else do that If tolls are acceptable, then take Skyway, else take I-80 If apples are large, then use only 2, else use 3 If 1000W microwave, then heat on high for 10 minutes, else if 500W microwave, then heat on high for 17 minutes, else use oven. Output 25

Algorithm specification Plain English (prose) Sequence of images Video sequence Hybrid These algorithm specifications are intended for humans They are not sufficiently clear for computers 26

Ingredients: Pastry for 2 crusts (recipe below) 8 cups sliced, peeled assorted baking apples - about 3 lbs. (Granny Smith, Cortland, Jonathan) 2 Tablespoons lemon juice 3/4 cup white sugar 1/4 cup brown sugar 1/4 cup all-purpose flour 1 teaspoon ground cinnamon 1/4 teaspoon ground nutmeg 2 Tablespoons butter 1 egg yolk 1 Tablespoon milk Directions: 1. In a large bowl, toss the sliced apples with lemon juice. 2. Combine sugars, flour, cinnamon and nutmeg; add to apples and toss well to coat. 3. Fill pastry lined 9 inch pie pan with apple mixture. Dot with butter. 4. Place second crust on top of pie filling, cut slits in top of crust to vent. Seal the edges of the crust with a fork or by hand. 5. In a small bowl, beat the egg yolk and milk. Brush mixture over top crust. 6. Bake at 425 degrees F for 15 minutes. 7. Reduce heat to 350 degrees F and bake 40-45 minutes more or until crust is golden and filling is bubbly. Not clear for computer Computer For how long? How high should I toss them? How many dots? How big are the dots? Where should they be placed? How many slits? What shape? Where? Fork or hand, how should I decide? What if in 20 minutes crust is golden and filling is not bubbly? Do I keep going? I might burn the crust? 27

iclicker question 7. Reduce heat to 350 degrees F and bake 40-45 minutes more or until crust is golden and filling is bubbly. What does this recipe fragment mean? A. If crust is golden and filling is not bubbly, keep baking until filling is bubbly, even if it means burning the crust. B. If crust is not golden and filling is bubbly, keep baking until crust is golden, even if it means drying out the filling. C. If crust is golden, stop baking regardless of whether filling is bubbly, to avoid burning the crust. D. If filling is bubbly, stop baking even if crust is not golden, to avoid drying out the filling. E. If crust is not golden or filling is not bubbly, keep baking, but use common sense, avoid burning crust or drying out filling. Stop as soon as crust is golden and filling is bubbly. 28

Not clear for computer For the computer some pixels are white some pixels are black 29

2 steps for specifying algorithms for computers (1) Pseudocode Fake code, almost code, quasi-code English language and mathematical notations for specifying algorithms Formatting and indentation rules Concise, precise Some syntax flexibility Computers cannot execute it (2) Program Algorithms specified using programming language Strict syntax rules Computers can execute programs Compilers create machine code Hardware executes machine code 30

Pseudocode motivation If computers cannot run pseudocode, why bother? Pseudocode is for humans, preliminary step before writing actual program Third tool for abstraction: focus on big picture first Allows designing algorithm w/o worrying about programming language details and rigors Allows algorithm analysis Memory consumption Running time Allows algorithm testing, debugging Humans can execute pseudocode and see algorithm output 31