Presentation is loading. Please wait.

Presentation is loading. Please wait.

What is an Algorithm? TechNights October 17, 2016.

Similar presentations


Presentation on theme: "What is an Algorithm? TechNights October 17, 2016."— Presentation transcript:

1 What is an Algorithm? TechNights October 17, 2016

2 An Algorithm Is… A step-by-step set of instructions for a specific task Clear and organized What algorithms do you know about?

3 Lego Construction Algorithm
Teams of four Look at the picture and build the object Write directions on the paper (an algorithm!) Trade pieces and directions with another team Follow the directions to build the object—2 minutes! Compare with the picture A total of 5 minutes for this exercise.

4 Lego Construction Algorithm
Can we do better? Give them 10 minutes

5 Problem-Solving Strategies
Our Toolbox Problem-Solving Strategies

6 “Brute Force”

7 How would you find the piece that fits?
Jigsaw – each girl should have one piece Give them 3-4 minutes

8 “Divide and Conquer” Give everyone a number. Sort yourselves!
Recursion!

9 Sort yourselves By Birthdays!
Volunteers – choose a girl to be a pivot for a couple groups Remember Quicksort?

10 Bisection How do we search effectively?
We run a binary search on the girls Whose birthday is closest to today?

11 Bisection

12 Bisection

13 Bisection

14 Bisection

15 “Greedy” Knapsack Problem

16 Limit: 20 pounds A. $1, 3 pounds B. $9, 4 pounds C. $5, 2 pounds
D. $9, 6 pounds E. $11, 7 pounds F. $6, 3 pounds G. $12, 5 pounds 1. Choose the best item 2. If it fits, put it in and go to step 1 3. If it doesn’t, put it aside and go to step 1 4. If there are no more items, stop 5. If your bag is full, stop 6. Otherwise, go to step 1

17 Choose the most ‘dense’
1. Choose the best item 2. If it fits, put it in and go to step 1 3. If it doesn’t, put it aside and go to step 1 4. If there are no more items, stop 5. If your bag is full, stop 6. Otherwise, go to step 1 A. $1, 3 pounds = 0.33 B. $9, 4 pounds = 2.25 C. $5, 2 pounds = 2.5 D. $9, 6 pounds = 1.5 E. $11, 7 pounds = 1.6 F. $6, 3 pounds = 2 G. $12, 5 pounds = 2.4 Answer they should get: $50 Also the optimal answer

18 How do I write a clear algorithm? What strategies can I use?
Reflection How do I write a clear algorithm? What strategies can I use?


Download ppt "What is an Algorithm? TechNights October 17, 2016."

Similar presentations


Ads by Google