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:
| ||||||
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, | Mon 6 Nov, Tue 31 Oct, Wed 25 Oct, Thur 26 Oct | |||||
(Lab 9 pdf) | Meteorological data processing and visualisation. the data files. | |||||
Lab 10, | Mon 13 Nov, Tue 7 Nov, Wed 1 Nov, Thur 2 Nov | |||||
(Lab 10 pdf) | Database programming under Unix. The special timing function. | |||||
Lab 11, | Set: Mon 27 Nov, Tue 14 Nov, Wed 8 Nov, Thur 9 Nov. | |||||
Due: Mon 4 Dec, Mon 27 Nov, Wed 15 Nov, Thur 16 Nov. | ||||||
(Lab 11 pdf) | A robot seaching for treasure in a maze.
sample maze;
alternate sample. | |||||
Lab 12, | Set: Mon 4 Dec, Tue 28 Nov, Wed 15 Nov, Thur 16 Nov. | |||||
Due: Mon 11 Dec, Tue 5 Dec, Wed 29 Nov, Thur 30 Nov. | ||||||
(Lab 12 pdf) | An automatic robot: he turned into a video game. |