1 / 55

Computer Science: Abstraction, Problem Solving, and Strategy

Discover the fundamentals of computer science, including abstraction, analysis, and problem solving. Learn strategies for playing tic-tac-toe and apply them to real-life scenarios. Explore different approaches to problem solving, from random guessing to binary search. Expand your thinking and enhance your problem-solving skills with computer science.

Download Presentation

Computer Science: Abstraction, Problem Solving, and Strategy

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. A bit of Computer Science is good for you no matter what you want to do DW Daniel High, SC; Jan 25, 2010 Murali Sitaraman RESOLVE Software Research GroupGoogle Terms: Clemson RESOLVE School of Computing, Clemson murali@clemson.edu

  2. Acknowledgments • Fox Filmed Entertainment • Marvel Studios • New York Times (Jan 24, 2010) • Software Development Topics, Timm Martin • 1001Crash.com • US National Science Foundation

  3. Computer Science is fun

  4. Computer Science is fun

  5. Computer Science is everywhere

  6. Computer Science is everywhere

  7. Computer Science is everywhere

  8. CS is serious business • Link

  9. CS is serious business

  10. CS is serious business

  11. CS has applications everywhere Arts Math Medicine Physical Sciences Engineering Finances and management … So job prospects are excellent with some computer science, but this talk is not about that

  12. What you learn in CS CS is as much about computers as teaching is about blackboards Not just about games or programming Something a lot more fundamental… Abstraction Analysis Mathematical logic Problem solving These fundamentals will help you no matter what your major is

  13. Let’s play

  14. Let’s play tic-tac-toe • Play with your friend a few times • Figure out a strategy

  15. Let’s play tic-tac-toe • Play with your friend a few times • Figure out a strategy (“algorithm”) • Can you always win? • Do you always lose?

  16. Do the colors matter?

  17. Do the shapes matter?

  18. What matters?

  19. Abstraction For the present problem Understand what is relevant Ignore the irrelevant It is the only way we can get a handle on large, complex problems There is a huge gap between the problems and the electrons running around in the computers There are several layers of abstraction Electrons, bits, bytes, programs are all abstractions!

  20. Strategies for solving tic-tac-toe Pick the middle square, if it is not taken ??? ???

  21. Strategies for solving tic-tac-toe If it is not taken Pick the middle square Pick a square if it would stop the other person from winning ???

  22. Strategies for solving tic-tac-toe If it is not taken Pick the middle square Pick a square if you would lose by not picking it! Pick a square if it would help you win!!

  23. A step-by-step procedure If it is not taken Pick a square if it would help you win!! Pick a square if you would lose by not picking it! Pick the middle square Pick a corner square (any one?) Pick a center-edge square (any one?) ???

  24. A program Repeat the following steps forever 1. If it is not taken Pick a square if it would help you win!! Pick a square if you would lose by not picking it! Pick the middle square Pick a corner square (any one?) Pick a center-edge square (any one?) 2. Quit if no square is available

  25. A program Repeat the following steps forever 1. If it is not taken Pick a square if it would help you win!! Pick a square if you would lose by not picking it! Pick the middle square Pick a corner square (any one?) Pick a center-edge square (any one?) 2. Draw a Circle; color it green; … 3. Quit if no square is available

  26. Generalization Questions Can you write a program for a 4 by 4 tic-tac-toe board? 5 by 5? n by n? 3-dimensional tic-tac-toe? k-dimensional tic-tac-toe? m by n, when m is not equal to n? What does it mean to win? What if some squares are blocked, i.e., no one can move there?

  27. Even More Questions Can the first player always win 3 by 3 tic-tac-toe? 2 by 2 tic-tac-toe? 3 by 3 by 3? …

  28. Toy problems to real ones Chess Deep Blue vs. Kasparov Map quest No adversary, but you’re trying to reach a goal through a bunch of moves; Closed roads are like blocked squares Wall street investment Airline reservations Computer is not intelligent; but the instructions better be!

  29. Basic questions about strategies Is our strategy efficient? Is it correct, i.e., can we guarantee the strategy will always work?

  30. More Problem Solving Ask your friend to guess a mystery number between 1 and 10 You can ask your friend only yes or no questions Figure out a strategy to find out the number

  31. More Problem Solving How many questions did you have to ask to unearth the mystery? What is the best case? What is the worst case?

  32. Approach 1: Random Pick a new number at random and ask if it is the mystery number

  33. Approach 2: Linear Start from number 1 and ask if it is the mystery number

  34. Approach 3: Novel? Is the number odd? If yes, is it divisible by 3? If yes, is it 3? Done. If not, is it prime? If yes, is it 5? Done. If not, Done If not, is it divisible by 4? If yes, is it 4? Done. If not, is it prime? If yes, done. If not, is it 6? Done.

  35. Approach 4: Binary Search Is the number greater than 5? If yes, is it greater than 8? If yes, is it greater than 9? Done. If not, is it greater than 7? If yes, done. If not, is it greater than 6? Done. If not, is it greater than 3? If yes …

  36. Analysis of the Approaches Approach 1 (random) vs 2 (linear) Best case 1 worst case 10 Random approach is more entertaining, but needs to store previous guesses Approach 3 (novel) vs 4 (binary) Best case 3 worst case 4 Novel approach is more entertaining, but requires more bookkeeping

  37. Linear and Binary Searches Suppose it takes 1 millisecond to ask a question and get an answer To guess a number between 1 and 10,000,000 Linear search requires about 3 days Binary search requires about 24 milliseconds Google would be really slow if it depended totally on linear search!

  38. Software Correctness First, we specify what problem needs to be solved Then we develop an efficient strategy for solving it and code it We can run code on some examples and see if it works (testing) Without ever running the code, we can prove that code is correct using mathematical logic! Software is unique in this way. Can’t do this for physical devices; they have wear and tear!

  39. Example Problem Specification Find the nearest, but smaller “whole number” square root of a given positive number For 25, the answer I want is 5 For 28, the answer I want is also 5 Can you specify what I want? Suppose x is the number I give you. Suppose y is the answer. What is the relationship between x and y?

  40. Problem Specification: Goal Can you specify what I want? Suppose x is a positive number I give you. Suppose y is the answer. What is the relationship between x and y? Goal: Find y such that (y * y) ≤ x ≤ (y + 1) * (y + 1)

  41. Linear Search Suppose x = 10,050. What is y? Try y = 1. Try y = 2. Try y = 3. Try y = 4. … Try y = 99. Try y = 100. Success!

  42. Binary search Suppose x = 10, 050. What is y? Try y = 1. Try y = 2. Try y = 4. … Try y = 64. Try y = 128. Too big. Try y = (64 + 128)/2 = 96. Too small. Try y = (128 + 96)/2 = 112. Too big. Try y = (96 + 112)/2 = 104. Too big. Try (104 + 96)/2 = 100. Just right!

  43. Is the binary search approach correct? Will it always terminate? Will it always produce y that satisfies the goal? (y * y) ≤ x ≤ (y + 1) * (y + 1) We can prove both these claims using mathematical logic, automatically!

  44. RESOLVE Research at Clemson

  45. Logical proofs because…

More Related