COMP1927 Miscellanities


In hardware everything has to be 100% correct, whereas in software there can be bugs, and mediocrity is expected.

Scanf’s need if statements around them to check they’ve returned the right amount. ALWAYS.


Style guide for lab marks:

  • Switches are fine
  • If in doubt ask your tutor
  • You can use multiple returns if justifiable – they cannot reject “to make my base case more explicit”

We must program defensively – check scanf’s etc


Memory Allocation Sizes:

  • Char buf[100] = 100 * 1 (Chars = 1 byte)
  • Int buf[100] = 100 * 4 (Ints = 4 bytes)
  • Double buf[100] = 100 * 8 (Doubles = 8 bytes)
  • Char *buf[100] = 100 * 4 (Pointers = 4 bytes)

a[i] = *(a+i) <- but how does it know to move 1 or 4 or 8 = based on the compiler’s knowledge of type sizes


Dynamic programming (which I don’t think we cover in this course) can greatly reduce time memory problems from basic recursive functions.
By this we mean that (for example) a Fibonacci program which just calls Fib(n-1) and Fib(n-2) will grow to huge levels of inefficient complexity very quickly. However caching (storing results) can dramatically improve this, by calling Fib(n-1) and Fib(n-2) only if there are not results stored for them, and else just querying that.

We'll definitely be tested on testing in the final (theory) exam; questions like 'what's the difference between black and white box testing?' etc