15 251 Great Theoretical Ideas in Computer Science Bits of Wisdom on Solving Problems Writing Proofs and Enjoying the Pain How to Succeed in This Class Lecture 4 September 4 2008 What did our brains evolve to do What were our brains designed to do Our brains probably did not evolve to do math Over the last 30 000 years our brains have essentially stayed the same The human mind was designed by evolution to deal with foraging in small bands on the African Savannah faulting our minds for succumbing to games of chance is like complaining that our wrists are poorly designed for getting out of handcuffs Steven Pinker How the Mind Works Our brains can perform simple concrete tasks very well And that s how math is best approached Substitute concrete values for the variables x 0 x 100 Draw simple pictures Try out small examples of the problem What happens for n 1 n 2 I don t have any magical ability I look at the problem and it looks like one I ve already done When nothing s working out then I think of a small trick that makes it a little better I play with the problem and after a while I figure out what s going on Terry Tao Fields Medalist considered to be the best problem solver in the world Novice Expert The better the problem solver the less brain activity is evident The real masters show almost no brain activity Simple and to the point Use a lot of paper or a board Quick Test Count the green squares you will have three seconds How many were there Bottles of water You have a 5 gallon bottle a 3 gallon bottle and lots of water How can you measure out exactly 4 gallons why New bottles of water puzzle You have a 6 gallon bottle a 3 gallon bottle and lots of water How can you measure out exactly 4 gallons Invariant Suppose stage of system is given by L S L gallons in larger one S in smaller Set of valid moves 1 empty out either bottle 2 pour bottle into other until first one empty 3 pour bottle into other until second one full Invariant L S are both multiples of 3 Generalized bottles of water You have a P gallon bottle a Q gallon bottle and lots of water When can you measure out exactly 1 gallon To come later in the course if P and Q have gcd P Q 1 that is they are relatively prime then you can find integers a and b so that a P b Q 1 How to use this And if you can measure out 1 What if gcd P Q 1 Exemplification Try out a problem or solution on small examples Look for the patterns A volunteer please Relax I am just going to ask you a Microsoft interview question Four guys want to cross a bridge that can only hold two people at one time It is pitch dark and they only have one flashlight so people must cross either alone or in pairs bringing the flashlight Their walking speeds allow them to cross in 1 2 5 and 10 minutes respectively Is it possible for them to all cross in 17 minutes Get The Problem Right Given any context you should double check that you read heard it correctly You should be able to repeat the problem back to the source and have them agree that you understand the issue Four guys want to cross a bridge that can only hold two people at one time It is pitch dark and they only have one flashlight so people must cross either alone or in pairs bringing the flashlight Their walking speeds allow them to cross in 1 2 5 and 10 minutes respectively Is it possible for them to all cross in 17 minutes Intuitive But False 10 1 5 1 2 19 so the four guys just can t cross in 17 minutes Even if the fastest guy is the one to shuttle the others back and forth you use at least 10 1 5 1 2 17 minutes Vocabulary Self Proofing As you talk to yourself make sure to tag assertions with phrases that denote degrees of conviction Keep track of what you actually know remember what you merely suspect 10 1 5 1 2 19 so it would be weird if the four guys could cross in 17 minutes even if we use the fastest guy to shuttle the others they take too long If it is possible there must be more than one guy doing the return trips it must be that someone gets deposited on one side and comes back for the return trip later Suppose we leave 1 for a return trip later We start with 1 and X and then X returns Total time 2X Thus we start with 1 2 go over and 2 comes back 1 2 5 10 1 2 5 10 1 2 5 10 5 10 21 1 2 5 10 5 10 21 1 2 5 10 5 10 2 5 10 21 1 1 2 5 10 5 10 2 5 10 21 1 1 2 5 10 5 10 2 5 10 2 21 1 1 5 10 1 2 5 10 5 10 2 5 10 2 21 1 1 5 10 1 2 5 10 5 10 2 5 10 2 12 21 1 1 5 10 5 10 1 2 5 10 5 10 2 5 10 2 12 21 1 1 5 10 5 10 1 2 5 10 5 10 2 5 10 2 12 2 1 1 5 1 1 5 10 10 2 5 10 5 and 10 Load Balancing Handle our hardest work loads in parallel Work backwards by assuming 5 and 10 walk together 1 2 5 10 5 10 2 5 10 2 12 21 1 1 5 10 5 10 1 2 5 10 Words To The Wise Keep It Simple Don t Fool Yourself That really was a Microsoft question Why do you think that they ask such questions as opposed to asking for a piece of code to do binary search The future belongs to the computer scientist who has Content An up to date grasp of fundamental problems and solutions Method Principles and techniques to solve the vast array of unfamiliar problems that arise in a rapidly changing field Representation Understand the relationship between different representations of the same information or idea 1 3 2 4 Abstraction Abstract away the inessential features of a problem Toolkit Name abstract objects and ideas and put them in your toolkit Know their advantages and limitations Exemplification Try out a problem or solution on small examples Look for the patterns Induction has many guises Master their interrelationship Formal Arguments Invariants Recursion Recurrences Modularity Decompose a complex problem into simpler sub problems Improvement The best solution comes from a process of repeatedly refining and improving solutions and proofs Bracketing What are the best lower and upper bounds that I can prove f x In …
View Full Document
Unlocking...