Computer Science Theory
- Reference sheet and cover page are available
- Covers everything in the course through today's lecture
- Questions are similar to the homeworks: mix of code and short answers
- In class, in room 420-41 (same as lecture)
Plan for Today
Today, we're discussing the theory of computer science
- Are there problems computers can't solve?
- What is an algorithm? What makes a "good" algorithm?
- Picture Contest!
- Developed the Universal Turing Machine to prove that some problems are unsolvable
- Broke Enigma encryption
- Turing Test in Artificial Intelligence
- Turing Award ("Nobel Prize of CS") named after him
Source: Keith Schwarz
- Abstraction (representation) of a computer
- Anything computable can be computed with a Turing Machine
- Idea: Infinite "tape" (memory)
- Move from one state (circle) to another by following the arrows and changing the memory as specified
- Accept or reject input - answers yes or no questions
- Anything we can do with computers we can do with Turing Machines
Turing Machine Fun
Google Doodle commemorating Alan Turing's 100th birthday
Idea: the "code" can change the input
- Turing machines can simulate running other Turing Machines (just like your computer can pretend to act as another computer)
- We use this fact to prove that we can never definitively say that a program will end
- Result: not all problems are solvable!
- Another undecidable problem: finding the cheapest sequence of flights for a trip
- Algorithm: way to solve a problem
- Two main resources: time and space (memory)
- Good algorithms run faster with respect to input size
- Getting the red value of a pixel always takes the same amount of time (constant)
- Green screen: double the width and height of the image, quadruple the number of pixels to look at (polynomial)
- Listing all the two digit numbers takes one-tenth the time as listing all the three digit numbers (exponential)
Algorithms in practice: Search
- We want to see if a certain value is in a sorted list of elements
- Could look through all the values one by one (polynomial)
- Binary Search
- Look at the middle value
- Only need to look at the left values if it's too big
- Only need to look at the right values if it's too large
Algorithms in practice: Sorting
- Bogosort: randomly pick all the elements, then check if the list is in order (really, really slow)
- Insertion Sort: Add the elements one-by-one
- Bucket sort: pick categories for the data, then put each item in one of those buckets
- Commonly used with exams
- Idea: faster if we relax our definition of "sorted"
P vs. NP
- Biggest unsolved question in Computer Science (million dollar prize)
- Basic idea: is it just as fast to solve a problem (NP) as it is to check that the solution is correct (P)?
P ≠ NP: Implications
- Encryption would break (we'll talk about this more in a couple weeks)
- Much better optimization (everything's faster!)
- Better transportation layouts
- Abstractions can help computer scientists think about problems differently.
- Some problems in computer science don't have any solutions (computers are not all-powerful).
- Some problems don't have any "good" solutions.
- There are lots of ways to solve problems! Computer scientists constantly try to find better ways.