Introductory Bits. Why computers use binary instead of decimal. | ||||||
Working out what six times nine is. Sometimes the simplest things are the hardest to do. The compilation cycle. Important for Mac owners. Operators and values. | ||||||
int, double, bool, string, char, %, ASCII, paper tape, and this. A bigger example, but a bit before its time. Do not be concerned with the details yet. Built-in mathematical functions. A sample of the first test. The need for pickiness and redundancy in programming languages. | ||||||
Scope (nore-or-less = curly brackets) different versions with same name, nothing changes. The program is utterly useless, it just illustrates some things that need to be illustrated. The extreme importance of your program having proper visual structure. This is just terrible. Recursion, first steps int controlling repetition. Displaying a count-down. First try, worked to start with, but didn't know to stop at 0, so we told it to stop at 0 and now it works perfectly. An addition to illustrate another useful effect of recursion.. | ||||||
(new mac instructions) The effect of holidays on due dates. exp(-x) * sin(10 * x) * cos(5 * x), x from 0 to 5, y from -1 to 1. z = sin(hypot(x, y)) * sin(pow(hypot(x - 5, y - 5), 0.8)), range -10 to 10. Adventures in graph plotting: just tabulating, sine wave, something more decorative, three dimensional. | ||||||
Lab 3. Better structure: first, second, axes. Find sum, minimum, maximum. | ||||||
Ten to the power ofs (v1), (v2), then twos, then use doubles. (correct figures for a double: 1 bit sign, 11 bits exponent, 52 bits mantissa) Printing numbers digit by digit backwards, backwards then forwards, forwards only, introducing arrays. Something similar but absurdly long. Starting on a better version. | ||||||
The completed number sayer. (those who have programmed before, how could this be done without recursion?) Here's how. Still no loops or variables though. Making our own sine function. | ||||||
Four steps towards our own sine function:
one,
two,
three,
four. Consider the big Os. | ||||||
Big-O meaning, Only care if time big => N big, highest term outweighs others, constant factor useless, expand from one measurement. Weird arithmetic. Physical human sorting. Examined some constant, linear, quadraric, and cubic functions/algorithms. And now the potential for a logarithmic one: lots of animals. | ||||||
Brownian motion. The while loop, allowed if expression is constant or function result. Screen savers and other mild entertainments. Back to the binary chop search on the animals. | ||||||
Finding integer square roots by binary chop search, the table proved unnecessary. Extending the method for doubles, when to stop? Counting steps is good. You can use cout instead of print now if you prefer. <iomanip> too. structs are a useful tool: A catalogue for the on-line animal shop. | ||||||
Using unix. | ||||||
Manipulating data range, the formula I had forgotten last week. Back to our square-root functions for a few minutes: Binary chop search, Newton-Raphson, NR with better first guess. Newton-Raphson with the exponent and mantissa trick is unbeatable for square roots and similar. Knapsack (all combinations) in three steps: one, two, three. | ||||||
How long would it take to solve the knapsack problem with 2000 packages? Some comparisons, but not close. Recent theories (^ is power of): 10^80 atoms in universe, 10^106 years until no matter left. Knapsack problem on a mere 2000 packages requires 2^2000 or 10^602 indivdual operations (actually worse, 2x10^605). If every atom in the universe turned into a 1THz supercomputer all working on this problem until the universe is all gone, only time for 3x10^205 operations. | ||||||
(Recorded)The triangle that turned into a fractal star, and the weirdness when the detours get sharper. Plotting the length of the Collatz sequence with a loop. The knapsack problem with variables, loops, and arrays. | ||||||
Day Off | 15th | |||||
Test preparation as needed. Be prepared with questions. | ||||||
First test. Do not use variables: functions and consts only. Questions as in the sample:
| ||||||
ASCII codes, the elements, Peter Pan. Working with files, <fstream>, ifstream, ofstream. | ||||||
Reformatting the file of chemical elements. The harder but more educational way, The easy way. (The mysterious problem solved by the print functions has vanished, so we'll never know) | ||||||
Word frequencies in Peter Pan. Handy tricks for sums of series. | ||||||
Starting from just the skeleton of a chemistry calculator, we can now process simple formulas in an annoying format. This is where we got. | ||||||
The importance of reference parameters. special struct vastly simplifies input to the chemistry calculator. | ||||||
The importance of being able to un-read input. A lot more progress with the chemistry calculator, It needs a bit of tidying up, I thing the ideal output format would be like this. | ||||||
Repeating Gaston Julia's experiments | ||||||
Julia sets, and
a nicer looking version. The mandelbrot set, sort of map of Julia sets, and an enhanced version, | ||||||
Second mid-term. Possible topics: General programming with variables and loops, Big-O, what it means and working it out, Strings and arrays, Basic structs, Files. First sample, and second sample. | ||||||
Break | 26th to 29th | |||||
Lab 1, | Mon 26th Aug - Thur 29th Aug. | |||||
(Lab 1 pdf) | Using visual C++ to run programs; drawing stars and stick figures. | |||||
Lab 2, | Tue 3rd Sep - Mon 9th Sep. | |||||
(Lab 2 pdf) | Divide and conquer: building big programs from little functions. | |||||
Lab 3, | Tue 10th Sep - Mon 16th Sep. | |||||
(Lab 3 pdf) | Controlling repetition in programs. | |||||
Lab 4, | Tue 17th Sep - Mon 23rd Sep. | |||||
(Lab 4 pdf) | A video game: blowing things up with a cannon. | |||||
Lab 5, | Tue 24th Sep - Mon 30th Sep. | |||||
(Lab 5 pdf) | A real-time animated clock application. | |||||
Lab 6, | Tue 1st Oct - Mon 7th Oct. | |||||
(Lab 6 pdf) | Generating calendars and using Unix. | |||||
Lab 7, | Not happening this semester due to last week's closure. | |||||
(Lab 7 pdf) | A happy street scene. | |||||
Lab 8, | Wed 16th Oct - Tue 22nd Oct. | |||||
(Lab 8 pdf) | An interactive desk calculator. | |||||
Lab 9, | Wed 23rd Oct - Tue 29th Oct | |||||
(Lab 9 pdf) | An interactive map, the data files: outlines and capitals. | |||||
Lab 10, | Wed 30 Oct - Tue 5 Nov | |||||
(Lab 10 pdf) | Database programming under Unix. The special timing function. | |||||
Lab 11, | Wed 6 Nov - Tue 12 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. |