Computer Science


Algorithms and Data Structures: COMPSCI 220 Semester 2, City Campus

Maths checklist

COMPSCI220 assumes that you are familiar with a number of notations and concepts from mathematics. Usually these are taught at school, but depending on your schooling background, you may have missed out on one or the other. Appendix E of the textbook is a place where help is at hand. Here is a quick refresher with a checklist that will let you assess whether you need to fill gaps.

This is what we expect students to be familiar with:

  • Set notation: { }, |, ∈, ∪, ∩, ⊂, ⊆, ⊃, ⊇, |...|, etc. A set X is simply an unordered collection of zero or more elements. For example, the integers from 3 to 7 form a set, which we can denote as, say, X={3, 4, 5, 6, 7}, but also as X={3, 5, 6, 7, 4}, or as X={x | x is an integer and x ≥ 3 and x ≤ 7} (read "the set of all x such that x is an integer and x is greater than or equal to 3 and x is less than or equal to 7". That is, we read "{x|...}" as "the set of all x for which [some condition applies]".

    To indicate that something is an element of a set, we say ∈, e.g., as in "if x=4 then xX".
    The number of elements in a set X is also called the set's cardinality and is denoted as |X| or sometimes also as #X.

    If we have a set Y whose elements are all also elements in X, then we call Y a subset of X and write YX if |Y|<|X| and YX if |Y|≤|X|. E.g., {4, 5, 7} ⊂ {3, 4, 5, 6, 7}. When YX, we also say that Y is a "true" subset of X.

    The subset notation can also be used the other way around: If YX then XY, and if YX then XY, and we call X a superset of Y.

    To indicate that Y has elements that are not also elements in X, i.e., that Y is not a subset of X, we write YX. For example, for Y= {2, 5, 7}, YX.

    If we have two sets X and Y, the set that contains the elements of X and the elements of Y is called the union of X and Y, denoted as XY. For example, for X={3, 5, 6, 7, 4} and Y= {2, 5, 7}, XY = {2, 3, 4, 5, 6, 7} = {x|xX or xY}.

    The set that contains the elements that are in both X and Y is called the intersection of X and Y and is denoted as XY. For X={3, 5, 6, 7, 4} and Y= {2, 5, 7}, XY = {5, 7}.

    If Y is a subset of X, the set Y that contains all elements of X that are not in Y is called the complement of Y and denoted as Y=X\Y.

    A set with no elements is called the emtpy set and is denoted as ∅.

    If X and Y have no common elements, i.e., XY = ∅, then X and Y are said to be disjoint.

    To see whether you are ready, test yourself by checking the statements below. Which one is wrong?
    1. If YX, then XY = Y.
    2. If |Y|>|X|, then |XY| < |X|.
    3. If |Y|>|X|, then YX.
    4. If YX, then |XY| ≤ 2|X|.
    If you found this easy, then you should be fine on this point. If you found this difficult, you will need help.

    (see also Appendix E.1 of the textbook)
  • Mathematical notation, in particular that for sums. A sum is denoted by Σ, the uppercase Greek letter for "sigma". It usually comes with (at least) a subscript, which can be either below the Σ or to the lower right of the Σ (this is a formatting issue, but there is no mathematical difference, e.g.:

    If there is only a subscript, it's generally a variable such as i or j and then it means "sum up the term after the Σ for all values of i (or j)". It should then usually be obvious from the context which values i or j can take.
    Or it could be something like "xX", in which case we sum up over all elements x in X, e.g., for X={2, 3, 5, 7, 11}:

    If there are a subscript and a superscript, like in the first example above, then the subscript gives the starting value for the variable, and the superscript the end value, and the variable increments by 1 for each term of the sum. Simple as that. Think of it as the mathematical version of a for-loop where you add a term to a sum in each iteration.

    To see whether you are ready, convert the following Java-style for-loop into a sum using the above notation (you do not worry about type conversion or integer division issues here):

    for (int i=0; i<=n; i++) { 1/(i+1) };
    

    If you found this easy, then you should be fine on this point. If you found this difficult, you will need help.

  • Floor and ceil notation: ⌈ x ⌉ rounds up to the nearest integer larger than or equal to x, e.g., ⌈ 3.2 ⌉ = 4. Similarly, ⌊ x ⌋ rounds down: ⌊ 3.2 ⌋ = 3.
  • Exponential functions. For integers i and any other real number a, ai is equal to a multiplied i times. E.g., 35 = 3 * 3 * 3 * 3 * 3 = 243. However, i does not need to be an integer and, in fact, often is not. The value a is called the base and i is called the exponent.

    Some simple rules that apply to exponential functions are:

    1. a-i = 1/ai.
    2. ai+j = ai * aj and ai-j = ai / aj.
    3. (ai)j = ai*j.

    You will need to know how to use these.

    Another thing that is very important to know is that exponential functions ai with a>1 grow very quickly in value as i increases.

    A special case of exponential functions is the exponential function ex, where e is Euler's (pronounced "Oil-ah") constant (approximately 2.718...). It is special because ex is its own derivative and, with the help of the natural logarithm ln (see below) all other exponential functions ai can be transformed into ex by setting x=i ln a.

    To see whether you are ready, figure out which of the following statements are true:

    1. ei-j = 1/ej-i.
    2. ak(i+j) > ak*i*ak*j.
    3. ai > a*i for a > 1 and all or almost all i>0.

  • If you found this easy, then you should be fine on this point. If you found this difficult, you will need help.

  • Logarithms. Logarithms are the inverse of exponential functions. So if ax = y, we write logay = x and say that "x is the logarithm to base a of y". Instead of log, you may also see lg without a subscript defining the base. This is often interpreted as shorthand for "logarithm to base 2" (which is used a lot in computing), "logarithm to base 10" (which is used a lot in engineering), or even "logarithm to base e (natural logarithm)". However, since these only differ by a multiplicative constant, which we will often be able to neglect in COMPSCI220, so you only have to guess ever so often!
    If you see ln x, then that always means logex (the "natural logarithm").

    The simple rules that apply to logarithms result from those for exponential functions (and why don't we use lg here just to get you used to it?):

    1. lg (x*y) = lg x + lg y.
    2. lg (x/y) = lg x - lg y.
    3. lg (xy) = y * lg x.

    Again, you will need to know how to use these. BTW: If you intend to take COMPSCI314 or COMPSCI742 at some point, this is a really good time to learn about logarithms as you will need them there, too!

    To see whether you are ready, figure out which of the following statements are true:

    1. lg (x+y) = lg x / lg y.
    2. lg (ax+y) = x * lg a + y * lg a.
    3. ak(i+j) > ak*i*ak*j.
    4. ai > a*i for a gt; 1 and all or almost all i>0.

    If you found this easy, then you should be fine on this point. If you found this difficult, you will need help.

    (see also Appendix E.4 of the textbook)
  • Proof by induction. Sometimes we'll want to prove that something (a mathematical statement) is true for all (typically non-negative) integers n, or at least for all integers n greater than or equal to some integer n0 (if it's meant to be true for all non-negative or all positive integers, then we choose n0=0 or n0=1, respectively). A common technique to prove this is called mathematical induction or simply induction. It involves proving first that the statement is true for n0 (sometimes called the basis). Then, one proves that if the statement is true for some n (the induction hypothesis), it must also be true for the next integer n+1 (the inductive step from n to n+1). This then completes the proof.

    Confused? Think of it as the mathematical equivalent of the domino effect (like this). If you can show that if domino number n falls over, domino number n+1 must also fall over, then your chain of dominos may or may not fall over - because one domino (domino n0) must make the start. If both these conditions are met, you know that all dominos for n greater than or equal to n0 will fall over.

    OK, but how does it work in maths? Example: Take Gauss's formula for the sum Sn of all integers from 1 to n: Sn=(n+1)n/2. How do we show that it's true? Choose n0=1. Then we know that S1=1, but we can also see that (n0+1)n0/2 = (1+1)1/2 = 1. So clearly the formula is correct for n=n0=1. That's our first domino falling over. Now comes the next step. To get from the sum Sn for all integers up to n to the sum Sn+1 of all integers up to n+1, all we need to do is add n+1 to Sn: Sn+1 = Sn + n+1. But our hypothesis says we know the formula for Sn: Sn=(n+1)n/2. So we can plug that in in place of Sn and get:

    Sn+1=(n+1)n/2 + n+1 = (n+2)(n+1)/2.

    which is the same formula, just for n+1 instead of n. So we've shown that if the formula gives the correct result for n, it also gives the correct result for n+1. That's our proof that the next domino will always fall over, and completes our proof of the formula.

This doesn't take long to grasp but makes life a lot easier when it comes to reading and understanding formulas!

In some contexts, we will also extend our insights systematically step-by-step using the established mathematical tools of definitions, lemmas, and theorems. A definitions is used to make it clear what a certain term means, what we are going to call something, or how we will be using a certain notation. A theorem is a statement we claim to be true, and it always requires a proof. A lemma is like a small theorem that we prove to lead us up to the proof of a more extensive theorem. As a general rule, we don't claim that something is true unless we can also prove it.

Appendix E of the textbook contains additional mathematical concepts that you need to know for the course: look at E.3, E.5, E.6, and E.7 - the tools above should help you understand most of it.

That's all, really.

Top


Apply now!


Handbook

Postgraduate study options

Computer Science Blog



Please give us your feedback or ask us a question

This message is...


My feedback or question is...


My email address is...

(Only if you need a reply)

A to Z Directory | Site map | Accessibility | Copyright | Privacy | Disclaimer | Feedback on this page