Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.

Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.

2,440 views

2,237 views

2,237 views

Published on

No Downloads

Total views

2,440

On SlideShare

0

From Embeds

0

Number of Embeds

5

Shares

0

Downloads

5

Comments

0

Likes

1

No embeds

No notes for slide

- 1. The best programmers I’ve meet knew how to sort a deck of cards pretty d*mn well Tony Tran
- 2. Image source: http://www.flickr.com/photos/60601862@N00/942476116/
- 3. What if… Given: Deck of playing cards Goal: To retrieve any card as fast as possible! Constraints: No real constraints, do whatever you want with the cards! Just don’t be a smart @s*! WHAT WOULD YOU DO!?!
- 4. Find me: Approaches: 1. Do nothing to the deck (Cost: 52 lookups) Cost is analyzed in worst case scenario. "Anything that can go wrong will go wrong.“ – Murphy’s Law
- 5. Approaches: 1. Do nothing to the deck (Cost: 52 lookups) 2. Group cards by suits (Cost: 4+12 = 16 lookups) 3. Group cards by faces (Cost: 12+4 = 16 lookups)
- 6. Approaches: 1. Do nothing to the deck (Cost: 52 lookups) 2. Group cards by suits (Cost: 4+12 = 16 lookups) =) 3. Group cards by faces (Cost: 12+4 = 16 lookups)
- 7. Image source: http://www.eyebrowmagazine.com/__data/assets/image/0010/10045/megan_fox_naked_5.jpg
- 8. What if… … Given: 99 note cards with a unique number written on each card. Goal: To retrieve any card as fast as possible! Constraints: No real constraints, do whatever you want with the cards! Just don’t be a smart @s*! WHAT WOULD YOU DO!?!
- 9. Find me: Approaches: 1. Do nothing to the deck (Cost: 99 lookups) 2. Create bins for groups of 100 and just throw the cards into the bin. Example: (Cost: 99 lookups) When given cards: 1,2,3,…,99 bins Cost is analyzed in worst case scenario. "Anything that can go wrong will go wrong.“ – Murphy’s Law
- 10. Find me: Approaches: 1. Do nothing to the deck (Cost: 99 lookups) 2. Create bins for groups of 100 and just throw the cards into the bin. (Cost: 99 lookups) 3. Sort the deck! Then perform binary search to find card. (cost: log2(99) lookups ~= 7 look ups) Depiction of binary search (does not show entire search) Cost is analyzed in worst case scenario. "Anything that can go wrong will go wrong.“ – Murphy’s Law
- 11. Find me: Approaches: 1. Do nothing to the deck (Cost: 99 lookups) 2. Create bins for groups of 100 and just throw the cards into the bin. (Cost: 99 lookups) 3. Sort the deck! Then perform binary search to find card. (cost: log2(99) lookups ~= 7 look ups) Depiction of binary search (does not show entire search) Cost is analyzed in worst case scenario. "Anything that can go wrong will go wrong.“ – Murphy’s Law
- 12. How does this apply to programming? Abstraction!
- 13. How does this apply to programming? Programming Problem --> Real Life Problem Abstraction!
- 14. Key point #1: 1. Being able to abstract a problem to something less complex, or more familiar, will make the problem easier! “the purpose of abstraction is not to be vague, but to create a new semantic level in which one can be absolutely precise.” - Edsger W. Dijkstra Image source: http://www.scientificamerican.com/media/inline/3E0F9160-E7F2-99DF-358998AA3C1A910F_1.jpg
- 15. Fans of abstraction What is the shortest path from 1 to any other node?
- 16. Keypoint #2: Abstracting a problem to a problem that has already been solved is even better! You don’t really have to do any work! INTERNET!!! “[OSPF] computes the shortest path tree for each route using a method based on Dijkstra's algorithm, a shortest path first algorithm.”
- 17. Keypoint #3 3. There’s no such thing as a dumb problem Problem: Given a spatula and a dish of pancakes (say 6 for now), how would you flip the pancakes such that the pancakes become sorted with the largest pancake at the bottom and smallest at the top? How many steps would it require? FLIP Initial State: GOAL Image source: http://sfist.com/attachments/SFist_Brock/pancakes.jpg
- 18. Someone familiar: SORTING PANCAKES == SORTING BY PREFIX REVERSAL Bill Gates & Christos Papadimitriou, Bounds For Sorting By Prefix Reversal. Discrete Mathematics, vol 27, pp 47-57, 1979. We referred to bounds as “Costs”
- 19. Key Points: 1. Being able to abstract a problem to something less complex, or more familiar, will make the problem easier! 2. Abstracting a problem to a problem that has already been solved is even better! 3. There’s no such thing as a dumb problem. 4. Be creative and have fun with problems. You have the ability to create an entire world at your fingertips!
- 20. -THANK YOU- New title proposal: The best programmers I’ve meet knew how to ABSTRACT PROBLEMS pretty d*mn well “The hardest part of solving a problem is to completely understand it to a point where you can see it from many different perspectives and abstractions” -A very wise T.A. Thank you, -Tony Tran @quicksorte r P.S. My gf will probably be reading this, so the story at the beginning didn’t really happen 0-=) But really, it didn’t =)

No public clipboards found for this slide

×
### Save the most important slides with Clipping

Clipping is a handy way to collect and organize the most important slides from a presentation. You can keep your great finds in clipboards organized around topics.

Be the first to comment