Algorithms -> Examples 1) An algorithm for tying your shoes. Pick up one lace in your left hand. Pick up the other lace in your right hand. Cross the left hand lace over the right hand lace. Pull the left hand lace from under the right hand lace. Put the lace from the right hand into the left hand. Pick up the other lace with your right hand. Pull the end of the laces away from each other until tight. Put a loop in the left hand lace. Put a loop in the right hand lace. Wrap the right hand lace around the loop in the left hand. 2) An algorithm for programming your vcr. Turn on the vcr. Set the TV to the vcr channel, (3 or 4) Press the "prog" button Select the type of program desired (one-time, daily, weekly) Press "enter" to get to next screen Use the right and left arrows to select the day Press "enter" Use the right and left arrows to select the hours Press "enter" Use the right and left arrows to select the minutes Press "enter" Use the right and left arrows to select am or pm Press "enter" Press the "prog" button. Turn the vcr off. 3) Read the following two different algorithms. Algorithm A Preheat oven to 350 degrees Move rack to middle of oven Measure 1/4 C butter and soften in large mixing bowl Measure 1 C sugar and add to button the mixing bowl Mix until butter and sugar are thoroughly combined. Add eggs to batter. Add 1/4 t vanilla to batter. Mix all ingredients thoroughly. Measure and add 3 1/2 C of flour to batter. Mix thoroughly until all batter is mixed Drop spoonfuls of cookie batter on ungreased cookie sheet. Place cookie sheet in oven Set timer for 10 minutes Wait for timer to beep Take cookies out of oven Use spatula to place individual cookies on rack to cool. Repeat steps 11 through 16 until all batter is used. Algorithm B Buy package of ready to bake cookie dough Preheat oven to 350 degrees Move rack to middle of oven Drop spoonfuls of cookie batter on ungreased cookie sheet. Place cookie sheet in oven Set timer for 10 minutes Wait for timer to beep Take cookies out of oven Use spatula to place individual cookies on rack to cool. Repeat steps 4 through 9 until all batter is used. What do each of these algorithms create? Deciding which algorithm to use. Some possible criteria to use to choose. Which algorithm is the least expensive? Which algorithm requires the least work (number of steps)? Which algorithm takes the least time to execute? (not always the least number of steps) Which algorithm cookies taste best? Which is the better algorithm? Which criteria did you use to choose? Algorithms -> Exercises 1) Write an efficient algorithm for moving your friend's things to a different apartment. 2) Write an inefficient algorithm for moving your friend's things to a different apartment. 3) Why is one algorithm more efficient than the other? Which criteria is probably most important if your friend is... a student? a shop owner? Bill Gates?