Download presentation
Presentation is loading. Please wait.
Published byJack Marshall Modified over 9 years ago
1
Computer Science School of Computing Clemson University 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 Group School of Computing, Clemson murali@cs.clemson.edu
2
School of Computing Clemson University Acknowledgments Fox Filmed Entertainment New York Times (Jan 24, 2010) Software Development Topics, Timm Martin 1001Crash.com US National Science Foundation
3
School of Computing Clemson University Computer Science is fun
4
School of Computing Clemson University Computer Science is everywhere
5
School of Computing Clemson University Computer Science is everywhere
6
School of Computing Clemson University Computer Science is everywhere
7
School of Computing Clemson University CS is serious business Link Link
8
School of Computing Clemson University CS is serious business
9
School of Computing Clemson University CS is serious business
10
School of Computing Clemson University CS has applications everywhere Arts Math Medicine Physical Sciences Engineering Finances and management … So your job prospects are excellent with a CS degree, but this talk is not about that
11
School of Computing Clemson University 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
12
School of Computing Clemson University Let’s play
13
School of Computing Clemson University Let’s play tic-tac-toe Play with your friend a few times Figure out a strategy… Can you always win? Do you always lose?
14
School of Computing Clemson University
19
Do the colors matter?
20
School of Computing Clemson University Do the shapes matter?
21
School of Computing Clemson University What matters?
22
School of Computing Clemson University 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!
23
School of Computing Clemson University Strategies for solving tic-tac-toe 1. Pick the middle square, if it is not taken 2. ??? 3. ???
24
School of Computing Clemson University Strategies for solving tic-tac-toe If it is not taken 1. Pick the middle square 2. Pick a square if it would stop the other person from winning 3. ???
25
School of Computing Clemson University Strategies for solving tic-tac-toe If it is not taken 1. Pick the middle square 2. Pick a square if you would lose by not picking it! 3. Pick a square if it would help you win!!
26
School of Computing Clemson University A step-by-step procedure If it is not taken 1. Pick a square if it would help you win!! 2. Pick a square if you would lose by not picking it! 3. Pick the middle square 4. Pick a corner square (any one?) 5. Pick a center-edge square (any one?) 6. ???
27
School of Computing Clemson University A program Repeat the following steps forever 1. If it is not taken 1. Pick a square if it would help you win!! 2. Pick a square if you would lose by not picking it! 3. Pick the middle square 4. Pick a corner square (any one?) 5. Pick a center-edge square (any one?) 2. Quit if no square is available
28
School of Computing Clemson University A program Repeat the following steps forever 1. If it is not taken 1. Pick a square if it would help you win!! 2. Pick a square if you would lose by not picking it! 3. Pick the middle square 4. Pick a corner square (any one?) 5. Pick a center-edge square (any one?) 2. Draw a Circle; color it green; … 3. Quit if no square is available
29
School of Computing Clemson University 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?
30
School of Computing Clemson University 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? …
31
School of Computing Clemson University 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!
32
School of Computing Clemson University Basic questions about strategies Is our strategy efficient? Is it correct, i.e., can we guarantee the strategy will always work?
33
School of Computing Clemson University 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
34
School of Computing Clemson University 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?
35
School of Computing Clemson University Approach 1: Random Pick a new number at random and ask if it is the mystery number
36
School of Computing Clemson University Approach 2: Linear Start from number 1 and ask if it is the mystery number
37
School of Computing Clemson University 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.
38
School of Computing Clemson University 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 …
39
School of Computing Clemson University 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
40
School of Computing Clemson University 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!
41
School of Computing Clemson University 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!
42
School of Computing Clemson University 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?
43
School of Computing Clemson University 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)
44
School of Computing Clemson University 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!
45
School of Computing Clemson University 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!
46
School of Computing Clemson University 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!
47
School of Computing Clemson University RESOLVE Research at Clemson
48
School of Computing Clemson University Logical proofs because…
49
School of Computing Clemson University Logical proofs because…
50
School of Computing Clemson University Logical proofs because…
51
School of Computing Clemson University Logical proofs because…
52
School of Computing Clemson University Notable Software Disasters Mariner bugs out (1962, $18.5 M) Hartford Coliseum Collapse($90M, ‘78) CIA gives Soviets the gas (priceless, ‘82) World War III…Almost (‘83) Medical Machine Kills (‘85) … Medical Machine Kills (2009) 20 Famous Software Disasters http://www.devtopics.com/20- famous-software-disasters/ http://www.devtopics.com/20- famous-software-disasters/
53
School of Computing Clemson University Frontiers… What problems can be solved with software? What problems are tractable? For the problems that are tractable, are the present solutions the best we can get? How do we design programs so that they can be proved correct? … Would software help you remotely “drive” your kids to school some day?
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.