Lab 07 - Compiling with Clang
Last updated
Last updated
Slides:
malloc()
- memory allocation
calloc(n, m)
- calculate the allocation. And it means allocate a memory space for n values, each of size m.
Note that calloc()
will "clear the memory" with 0 before it returns the pointer back. So that is why we are recommended to use calloc()
!
If you don't do Null Pointer Check, you will be penalised in PE
Use math to simplify the algorithm
An idea to ignore the leading zero is to use start print from the first nonzero element if the result is not 0.
clang -I
, -I
stands for "include"
Remember the way to allocate a 2-D array (with null pointer check)
If the contiguous memory method, the code below
This will define the starting point for each row.
Due to array decay, the address of an array is the same as the address of its first element.
means f(x) is upper bounded by g(x). or , which means set of all functions which do not grow more slowly than f.
Include the trivial results about Big O calculation in the cheatsheet.
If you have two inputs m
and n
, you should include both variables because they are independent.
The real way to compare growth rate is to take the limit.