Lec 4 | MIT 6.00 Introduction to Computer Science and Programming, Fall 2008 - 51:27

http://www.youtube.com/watch?v=SXR9CDof7qw&feature=BFa&list=PL7BC1DAED2189CFA6

So far we have assignment, conditionals, input/output, and looping constructs. This has given us a Turing complete language, enough to write any program. To write code we write it all in one long file. We lack decomposition and abstraction, and that's what we'll add now. Decomposition is breaking up code into modules, reusable, that isolate components of the process. One mechanism for that are functions. They let us break up into modules, suppress detail and let us make new primitives. Syntax of a function: def

Enumerate and check is an example of a brute force algorithm. Instead of using formulas to solve equations we use for loops to iterate through all the possibilities until we find the correct one.

If a function returns a topple with return (x, y) then we can get that answer with x, y = function(x, y). Tooples and lists are very similar and in most cases can be interchanged.

Recursion is when a function calls itself. Base case is the simplest possible solution to the problem. Inductive step is breaking the problem into simpler version of the same problem and other steps. A good example of recursion is Fibonacci.

- Current Mood: happy
- Current Music:Wicked And Weird - Buck 65