Wednesday, September 18, 2013

Software for students

For new computing students finding affordable, legitimate software and tools to get started with course content, personal projects and solutions for software development competitions (e.g. Imagine Cup and Teleios Code Jam) may be a challenge. Nigel Sammy has compiled a list of options for Microsoft software and tools on his blog:

Nigel Sammy - Blog: Free Microsoft Software and ToolsBefore you get too excited this isn't a situation where I am giving away any software. It also is not a promotion or a scam, it is about legitimate sites and programs that offer Microsoft software and tools for various time periods...

Monday, June 24, 2013

Learn about industry

When students are studying full-time they may not necessarily think about the industry or job market they will be entering. The primary focus is usually the immediate future and the immediate future is usually some deadline for an assignment or exam. It can be useful to be aware of what roles exist, have a sense of the responsibilities of each role, have an idea of which roles appeal to you and what are the skills employers typically request. It also helps to know about recent developments are in your field.

There are convenient ways to get this information. If you are a user of social media, then let social media work for you. On Facebook, Twitter and LinkedIn you can like and follow thought leaders, groups, agencies and companies in your field. Subscribe to job alerts on recruitment websites or companies for which you would like to work. Some companies even offer programmes for recent graduates, so do a bit of research to see what opportunities may become available to you upon graduation. Of course there's always the traditional route of browsing your daily newspaper.

The suggestions may seem pretty obvious to some but they are often overlooked by many students simply because it's not the current focus. For my IT students here are a few recommendations to get started:



Monday, May 20, 2013

Why would you leave an exam early?

As a student, and more so now as an instructor, it baffles me when I see students leave an examination early. Did they suddenly take ill? No. Did they get a perfect score? Negative. Is there some prize for leaving early? None. Then why did they leave?

Even when you think you've answered every question to the best of your ability, the remaining time can still be used to review your work, as many times as your time allows. Reviewing your work begins with the question, not with your solution. Reread the questions and ensure that they were interpreted correctly. Then review the solutions, redoing calculations where applicable. Mistakes can be made when using a calculator too! In some cases it is even possible to verify that the answer found is correct (e.g. by using another method or substituting the results to ensure that they satisfy all parts of the question.) Maybe in your haste your penmanship deteriorated. In this case you can use the time to rewrite parts of your solution more legibly.

Even when you draw a complete blank in an exam, it is in your best interest to stay. Take a few deep breaths and calm your nerves, then try the question again. You never know what you can remember unless you take the time to try to remember.

If you are a student who has left an exam early please share your reasons in the comments below.


Wednesday, May 15, 2013

Euclidean Algorithm


The Euclidean algorithm is a method to find the greatest common divisor of two positive integers, a and b, where a > b. We can denote the greatest common divisor of a and b as gcd(a,b)

The Euclidean algorithm is based on the following:

  • If a and b are positive integers, there exist integers unique non-negative integers q and r so that a = bq + r , where r < b.
  •  \(a = bq + r \rightarrow gcd(a,b) = gcd(b,r)\)
  • gcd(z,0) = z, for any integer.

Algorithm steps:

  1. Express a in the form a = bq+ r.
  2. End if r = 0 and report b as the gcd. Otherwise b becomes our new a and r becomes our new b and repeat step 1.



Let's find the greatest common divisor of 732 and 345 using the Euclidean algorithm.

\begin{align*}
732 &= 345(2) + 42
\\345 &= 42(8) + 9
\\42 &= 9(4) + 6
\\9 &= 6(1) + 3
\\6 &= 3(2) + 0
\end{align*}

From above it follows that gcd(732,345) = gcd(345,42) = gcd(42,9) = gcd(9,6) = gcd(6,3) = gcd(3,0) = 3.


A common mistake is to report that the gcd(a,b) is the quotient, q, in the final line. In this case some might erroneously report gcd(732, 345) = 2. It helps to remember the second point above to avoid committing this mistake. The gcd is the last non-zero remainder.

Sunday, April 28, 2013

Transitive Closure

The closure of a binary relation R on a set A, with respect to a property (reflexivity, symmetry, transitivity) is a relation which meets the following three criteria.

  1. The relation contains R.
  2. The relation possesses the property.
  3. The relation has the fewest number of ordered pairs that satisfies both criteria listed above.


The reflexive closure of R is given by \( R \cup \left \{(x,x): x \epsilon A\right \}\).
The symmetric closure of R is given by \( R \cup \left \{(y,x): (x,y) \epsilon A\right \}\).


Finding transitive closure is not as simple. Consider the relation \(R = \left \{(1,2), (3,1), (1,4), (4,3)\right \}\). We may be tempted to think that the transitive closure is given by \(R \left \{(3,2), (3,4), (1,3), (4,1)\right \}\). This new relation satisfies property 1 above but does it satisfy 2? No, it is missing (1,1), (3,3) and so on.

One method to find the transitive closure is to use Warshall's algorithm. Given a relation R on set A (which has n members), Warshall's algorithm takes as input the n x n 0-1 matrix representing R,  \(M_{R}\), and outputs a matrix representing the transitive closure of R,  \(M_{R^{*}}\).

Warshall's Algorithm:

\(for \ k = 1\  to\  n\)
    \(for\  i = 1\  to\  n\)
        \(for\  j = 1\  to\  n\)
            \(w_{ij} = w_{ij} \vee (w_{ik} \wedge w_{kj})\)

Examining the innermost loop we note that only j (which represents our columns in our matrix) is changing. The counters i and k remain constant. 

If \(w_{ik}\) is 0 then the row remains unchanged since  \(w_{ik} \wedge w_{kj}\) evaluates to 0.

If \(w_{ik}\) is 1 then \(w_{ij}\) takes the value of \(w_{ij} \vee w_{kj}\). If \(w_{ij}\) is 1 it stays as 1. If \(w_{kj}\) is 1 then \(w_{ij}\) is updated to 1. In other words we replace the \(i^{th}\) row with the result of boolean addition of the \(i^{th}\) and \(k^{th}\) rows.

Let's look at an example. Let's find the transitive closure of R={(1,1), (1,3), (2,1), (3,2)} using Warshall's algorithm.

\(M_{R} =\begin{bmatrix} 1  &0 &1 \\1  &0 &0 \\ 0  &1 &0\end{bmatrix}\)

\(k = 1: W_{1} = \begin{bmatrix} 1  &0 &1 \\1  &0 &1 \\ 0  &1 &0\end{bmatrix}\)

\(k = 2: W_{2} = \begin{bmatrix} 1  &0 &1 \\1  &0 &1 \\ 1  &1 &1\end{bmatrix}\)

\(k = 3: W_{3} = \begin{bmatrix} 1  &1 &1 \\1  &0 &1 \\ 1  &1 &1\end{bmatrix}\)

So, \(M_{R^{*}}\) = {(1,1), (1,2), (1,3), (2,1), (2,3), (3,1), (3,2), (3,3)}

Tuesday, April 9, 2013

Would you want to work with you?

At the start of every semester I like to ask my students why are they in this class or why have they enrolled in this particular programme. Popular responses include meeting some parental demand to pursue higher education, meeting some contractual obligation to an existing employer, needing a degree to get a job. Not very many students respond that it is a path towards their chosen career. Your reasons for pursuing higher education influence your approach to your studies and ultimately the type of work ethic you develop that you take with you into industry. Even if you're not enthusiastic about your field, people should be enthusiastic to work with you.

It's natural to be motivated when you are passionate about your field and excited to join industry as a <insert job role here> but not everyone embarks on a course of study knowing what type of professional roles exist in the field and which of those roles appeal to them. If you're lucky you may find yourself in a programme that exposes you to opportunities to learn about career options and will interact with instructors who get you excited about the field thereby changing your outlook. You may even research your career options on your own and discover roles that appeal to you. But if this enthusiasm never develops the danger is that you will not reap the full benefits of your programme and habits will develop that you will likely take with you into industry.

You may begin to focus on graduation as though it is the final goal and forget that there is life after. You need to remain mindful that the student you are today will likely dictate the worker you will be tomorrow. Examine yourself and your work ethic often. Are you focused on simply finishing or excelling? Do you strive to meet deadlines or consistently seek extensions? For group work, do you do your fair share and in a timely manner or do others dread working with you? Do you wait for answers or do you seek them? You may not be passionate about your field but you should strive to be praiseworthy.

After this programme you will be employed and you will be expected to deliver in whatever role you have. Be mindful of the person you are becoming. Who do you want to be...or rather, who would you like to work with?








Thursday, March 21, 2013

Addition and Simplification Laws

In logic the addition law and simplification law are sometimes misused.

Law of Addition

\(p \rightarrow p \vee q\)

This law states that if a proposition \(p\) is known to be true then the disjunction of  \(p\) with any other proposition will also be true.

Law of Simplification

\([(p) \wedge (q)] \rightarrow p \)

also,

\([(p) \wedge (q)] \rightarrow q \)

This law states that if the conjunction of \(p\) and \(q\) is true then we can deduce \(p\) is true. Similarly, we can deduce \(q\) is true. Remember that \([(p) \wedge (q)]\) is true only if both propositions \(p\) and \(q\) are true. That's why we can deduce \(p\)  is true and that \(q\) is true.

Some students attempt to apply the law of simplification to a disjunction. Without knowing the truth values of \(p\) and \(q\) some students may deduce from the statement \( p \vee q\) that \(p\) is true or that \(q\) is true. This is not valid. From \( p \vee q\) we know that at least one of the propositions is true, but we do not have enough information to know which one of them is true.

Tuesday, March 12, 2013

Finding a Formula when Solving Recurrence Relations using Induction

Induction is a popular technique for solving recurrence relations that involves guessing the formula instead of deriving it through computation. Induction is then used to prove that the formula found by conjecture is valid for the given recurrence relation.

Some people have a natural gift for noticing patterns in numbers and may actually conjecture the formula with ease. Others may struggle with this approach at first but after practising with a variety of problems may discover that finding the formula can be an almost enjoyable task.

Tips for finding the formula:

  1. List about 3-5 iterations of the relation. On your first pass, don't sum or calculate products or simplify the expression. The pattern may be easier to see with the expression in this form. If no pattern is obvious, then simplify.
  2. Identify which values remain constant in each iteration.
  3. Identify which values change with each iteration.
  4. Do you notice a sum of values? A product? Is the product some value raised to an exponent/power?
  5. Identify the relationship between the number of the iteration and the changing values.
Example:

Suppose we would like to find a recurrence relation for \(s_0 = 3, s_k = s_{k-1} + 2k\) for all integers \(k >=1\)

\(s_0 = 3\)
\(1^{st}\) iteration:  \(s_1 = 3 + 2.1\)
\(2^{nd}\) iteration: \(s_2 = 3 + 2.1 + 2.2\)
\(3^{rd}\) iteration: \(s_3 = 3 + 2.1 + 2.2 + 2.3\)

From this we can see that the first term, 3, remains constant and 2 is a factor of the remaining terms. So we get

\(s_0 = 3\)
\(1^{st}\) iteration:  \(s_1 = 3 + 2(1)\)
\(2^{nd}\) iteration: \(s_2 = 3 + 2(1 + 2)\)
\(3^{rd}\) iteration: \(s_3 = 3 + 2(1 + 2 + 3)\)

The values inside the brackets change on each iteration and here we have a sum of terms. But how do we generalise? Well we look for a relationship between the number of the iteration and our changing values. In this example, in our \(k^{th}\) term we have 1 + 2 + ...+ k. This is the sum of an arithmetic sequence where a = 1 and d = 1. The sum of the first k terms in an arithmetic sequence is given by \(\frac{k}{2}(2a + (k-1)d)\).
Since a = 1 and d = 1 then. \(1 + 2 + ... + k = \frac{k(k+1)}{2}\)

So our final solution is
\(s_n = 3 + 2 \frac{n(n+1)}{2}\)
\(s_n = 3 + n(n+1)\)



Depending on the complexity of the recurrence relation you may not be able to conjecture a formula easily but there are methods for solving recurrence relations that involve identifying the type of recurrence relation and using an appropriate known closed-form formula.See this article for more details.

Monday, February 25, 2013

Independent and Mutually Exclusive Events

Consider the task of tossing a die and flipping a coin at the same time. Let Hn denote that the coin landed on heads and n was tossed on the die and let Tn denote that the coin landed on tails and n was tossed on the die.

The sample space for this experiment is

S = {H1, H2, H3, H4, H5, H6, T1, T2, T3, T4, T5, T6}

Let A be the event that an even number was tossed on the die.
Let B be the event that a number divisible by 5 was tossed on the die.
Let C be the event that the coin landed on heads.

Let's represent these events as sets.

A = {H2, H4, H6, T2, T4, T6}
B = {H5, T5}
C = {H1, H2, H3, H4, H5, H6}

P(A) = 6/12 = 1/2
P(B) = 2/12 = 1/6
P(C) = 6/12 = 1/2

Since there is no number between 1 and 6 that is both even and divisible by 5 the events, A and B, cannot take place simultaneously. A and B are said to be mutually exclusive events or in other words their sets do not intersect.

The probability that A or B takes place may be calculated as follows:
P(A or B) = P(A) + P(B) = 1/2 + 1/6 = 4/6

Since it is possible for an even number to be tossed on the die and for the coin to land on heads simultaneously then A and C are not mutually exclusive. In fact A ∩ C is a non-empty set,  A ∩ C = {H2, H4, H6}.

Two events are considered independent when the outcome of one does not influence the outcome of the other. In other words, the success of one event does not affect the probability of the other event. A and C are independent events and B and C are independent events since the side the coin lands on is in no way affected by the number tossed on the die.

Since A and C are independent, the probability that A and C take place simultaneously may be calculated as follows:
P(A and C) = P(A) × P(C) = 1/2 + 1/2 = 1/4

How do we calculate the probability of A or C? Since A and C are independent we use the following formula:
P(A or C) = P(A) + P(C) - P(A and C) = 1/2 + 1/2 - 1/4 = 3/4


Test yourself, are events B and C mutually exclusive? How would you calculate P(B or C)?

Thursday, February 21, 2013

Proof by Contradiction

One strategy for proving the validity of an argument is Proof by Contradiction which is based on the Reductio ad Absurdum (Latin for "reduction to the absurd") argument.

In this type of proof, we usually assume the negation of the conclusion. We use this assumption together with the other premises to derive a result. This result is either already known to be false or can be shown to be false. Since the result cannot both be true and false then it follows that the initial assumption must be false i.e. the conclusion holds.

Let's use propositional logic and the Proof by Contradiction approach to prove the following argument.

Either Veronica is not from Riverdale or Dilton is not smart.
Dilton is smart.
If the Lodges did not move then Veronica is from Riverdale.
Therefore the Lodges moved.

Let R be the proposition "Veronica is from Riverdale."
Let S be the proposition "Dilton is smart."
Let M be the proposition "The Lodges moved."




Wednesday, February 20, 2013

Distractions

According to Google Dictionary:

    dis·trac·tion
    noun /disˈtrakSHən/ distractions, plural
    1. A thing that prevents someone from giving full attention to something else
      • - the company found passenger travel a distraction from the main business of moving freight
    2. A diversion or recreation
      • - there are plenty of distractions such as sailing


Mobile games, text messages, IM, email, the WWW, friends - all possible distractions to a student  (definition 1) while in class. The further you sit to the back of a classroom, you think, the less noticeable you are and the more tempted you are to indulge in these distractions. Some teachers actually pay more attention to those in the back rows for this very reason.

Why do you choose to be distracted when you've already done the hard part? You've made it to class. You're here. At the very least you could listen. And while you're at it, why not take some notes and participate? It's all been (or being) paid for - the tuition, the transportation, the books, the stationery. Somebody's paying for them, if not you, then your parents or the institution or the government or some sponsor. So much can be gained during these contact hours with your teacher and your peers. Listen. Engage. Learn.

The truth is, mobile games, text messages, IM, email, the WWW, friends are distractions (definition 2) that will still be available after class for you to enjoy.

Proofs and Equality of Equivalence Classes

Courses in Number Theory require students to prove various theorems. In some cases, as you construct your proof you will find that you need to show that two equivalence classes are the same. In these cases it is useful to remember the relation that is involved. If two elements are related then these elements belong to the same equivalence class.

Consider the following proof exercise:

Show that \(x+0=0\) for every \(x \epsilon  \mathbb{Z}\)

Proof:

Let \(x = [a,b]\) and recall that \(0 = [1,1]\).

Recall the definition of integer addition i.e. \([r,s] + [t,u] = [r+t, s+u]\).

So,  \(x + 0 = [a, b] + [1, 1] = [a+1, b+1]\).

We need to show that \([a+1, b+1]  = [a,b]\).

Recall that  \(\mathbb{Z}\) is the set of equivalence classes of R where R is the relation on \(\mathbb{X}\) such that \((a,b)R(c,d)\) means \(a+d=b+c\) and \(\mathbb{X}\) is the set of ordered pairs \((a,b)\) of natural numbers.

\((a+1,b+1)R(a,b)\) since \(a+1+b = b+1+a\)

Thus, \([a+1,b+1]=[a,b]\) and the result holds.