| Introductory bits. Working out what six times nine is. Sometimes the simplest things are the hardest to do. The compilation cycle. | ||||||
| Why computers use binary instead of decimal. Modern programming languages are maniacally picky, but for good reason. Important for Mac owners. Operators and values. | ||||||
| Solving quadratic equations: step 1: Simplest possible approach just to get started step 2: That used square root of a negative, this uses numbers that allow a solution step 3: Named constants have many benefits step 4: A conditional avoids the square root of negatives step 5: This also notices when there is only one solution step 6: User interaction is more flexible and useful step 7: Two simple new functions make a nice improvement Listing the numbers between 0 and 10: first incomplete version, and the correct version. | ||||||
| A brief guest presentation. Stack frames/activation records - little boxes of memory where functions remember their details. Plotting a graph. | ||||||
| Storage media (a slight aside). Important graphics functions and some words about lab 2. Programs should not use the words while, do, or for until further notice. Programs should not use the word goto ever. A closer examination of recursion and some more compelling examples: Graph plotter, first mystery, half of it, separating the digits of a number. | ||||||
| Good design example: define one constant (width) and make others be a proportion of that. More recursive divide-and-conquer design: Printing numbers in words, just the digits, Introducing arrays to make that more compact, Plotting a graph that needs scaling, Spirographs, Calculating and listing powers of two. | ||||||
| Good design: make function leave things exactly as they were when possible. Plotting a 3D graph, the z axis is represented by colour: z = sin(hypot(x, y)) * sin(pow(hypot(x - 5, y - 5), 0.8)), range -10 to 10. An absurdly long program, and the tiniest beginnings of an improvement. | ||||||
| The complete number speaker, very important to understand the recursion. (A little aside about capitalising the first letter). First look at an important example function, be sure you understand it. | ||||||
| Lots of useful recursive functions. There are some (voluntary) exercises to try at the end of that document. | ||||||
| Teletypes, paper tape, ASCII in action, parity bits, case sensitivity: the teletype, its keyboard. A decorative but very bad program. Defining our own sine function. | ||||||
| HKN tutoring, schedule near the top of this page. Simulating Brownian Motion, prep for clock lab. Examining the accuracy and improving the efficiency of our sine function. Searching an array of animals. | ||||||
| The binary chop search method. Measuring time and memory needs, the big O notation. A bit more about the weird z, s(z), s(s(z)) stuff. Binary chop search time is O(log(N)), we have already seen another logarithmic time algorithm. | ||||||
| Using Unix (needed for next lab), commands to remember: passwd, pico, CC, ls, cp, mv, mkdir, cd, man, exit, logout. If you plan to go much further in computing, before long you should learn to use an editor that is seen as more professional than pico or nano. The best is called emacs, but for some reason vi is more popular. The normal Unix libraries. | ||||||
| remember to use the patterns and practise a lot. covered cat, pasting, cal, paths, grep (just a little), and editing technique. Finding square roots with a binary chop search on an array of squares, The array wasn't necessary, if A[n] always = n*n, just write n=*n instead of A[n], Now extending it to find square roots of any number surprisingly makes it easier, The Newton_Raphson method is quite neat and even faster. | ||||||
| Questions about the mid-term. More recursion practise. | ||||||
| First mid-term exam. First sample test, and another one. | ||||||
| Day off | 14th | |||||
| Further exploration of O(), the speed (or slowness) of algorithms: A faster sorting method, two exponential algorithms, and a cubic one - matrix multiplication as needed for video games. Matrix operations: step 1, step 2, step 3, step 4, step 5, step 6. | ||||||
| Reading data from files. Bitwise (binary digit) operators. How random numbers are generated. A few uses of loops. Update operators +=, *=, /=, etc, and the less safe ++ and --. | ||||||
| The mysterious Collatz sequence, establishing correctness. The triangle that turned into a snowflake then a fractal star, Measuring the perimeter of a fractal. | ||||||
| More working with files, in particular one that contains the periodic table. The beginnings of the chemistry calculator: read a formula and print its molecular weight. All we got to was checking that we had read the file correctly. | ||||||
| Review of three function patterns that it is essential to understand, and one more. Converting strings, e.g. "742" -> 742, and other string manipulations. Introducing structs by implementing fractions as a new data type. More of the chemistry calculator: Transfering the file's data into arrays, First steps in the calculator, e.g. type "Ca S O 4 ." and get mol. wt. of Calcium Sulphate. | ||||||
| Completing the fractions implementation, normalisation and euclid's gcd algorithm. Improving the structure of the chemistry calculator by using structs, and introducing a method. | ||||||
| More on constructors. .peek() and .get() are useful for complicated input, they made the chemistry calculator much better. | ||||||
| the BNF specification. The complete chemistry calculator, multiple nested (xxx). | ||||||
| Second mid-term exam. Files, structs, string manipulations, handling complex input, big-Os. a sample, and another one. | ||||||
| repeating Gaston Julia's experiments. | ||||||
| Break | 25th to 30th | |||||
| Lab 1, | Mon 25th Aug - Thur 28th Aug. | |||||
| (Lab 1 pdf) | Using visual C++ to run programs; drawing stars and stick figures. | |||||
| Lab 2, | Tue 2nd Sep - Mon 8th Sep. | |||||
| (Lab 2 pdf) | Divide and conquer: building big programs from little functions. | |||||
| Lab 3, | Tue 9th Sep - Mon 15th Sep. | |||||
| (Lab 3 pdf) | Controlling repetition in programs. | |||||
| Lab 4, | Tue 16th Sep - Mon 22nd Sep. | |||||
| (Lab 4 pdf) | A video game: blowing things up with a cannon. [the function int random_in_range(const int a, const int b) returns a random int between a and b inclusive]. | |||||
| Lab 5, | Tue 23rd Sep - Mon 29th Sep. | |||||
| (Lab 5 pdf) | A real-time animated clock application. | |||||
| Lab 6, | Tue 30th Sep - Mon 6th Oct. | |||||
| (Lab 6 pdf) | Generating calendars and using Unix. | |||||
| Lab 7, | Tue 7th Oct - Mon 20th Oct. | |||||
| (Lab 7 pdf) | A happy street scene. | |||||
| Lab 8, | Wed 15th Oct - Mon 27th Oct. | |||||
| (Lab 8 pdf) | An interactive desk calculator. | |||||
| Lab 9, | Wed 22 Oct - Mon 3 Nov. | |||||
| (Lab 9 pdf) | Meteorological data processing and visualisation. the data files. | |||||
| Lab 10, | Tue 4 Nov - Mon 10 Nov | |||||
| (Lab 10 pdf) | Database programming under Unix. The special timing function. | |||||
| Lab 11, | Tue 11 Nov - Mon 17 Nov | |||||
| (Lab 11 pdf) | A robot searching for treasure in a maze.
sample maze;
alternate sample. | |||||
| Lab 12, | Wed 13 Nov - Tue 19 Nov | |||||
| (Lab 12 pdf) | An automatic robot: he turned into a video game. | |||||