Wednesday, 3 December 2014

Bitter, Sweet Moments of CSC165

Hello everyone! As we all know finals are coming up and we are at the end of CSC165. I must say there were many bitter sweet moments of this course. This course has challenged me more than anything I have ever faced so far. It is a tough course with many trials and tribulations that allowed me to explore the world of weird logic. A part of me will miss it but a part of me will be set free before the exam is over, provided that I do not die during the examination of course. I have faced some disappointments and some successes with both assignments and midterm tests. Guess what! You will never learn once you do not have some failures. I enjoyed the problem solving work sheets Professor Heap used to give us. I thought he was a good lecturer in my opinion as well as my TA, Madina. Some of the simplest scenarios can have some of the most “complex” algorithms to create. Who knew folding paper and counting pennies can have algorithms? That is the beauty of Computer Science; you never know what problem you are going to be presented with next. Last but not least, we have the almighty proofs. That was the most frustrating topic that I have ever done. Actually solving the proof was probably the best part.

Good luck for the rest of the year! Thank you for reading my blog!
                               

The CSC165 is almost over expression


Halting Struggles

Today, we are going to discuss the topics of halting and computability. This topic in particular has my mind wrapped up in spirals of confusion but I will still try to decode its meaning. From what I have read in the slides, we have to be able to look at a code, decipher an algorithm to decide if it halts without actually running. There are two possible things that can occur with the code, it can either halt or do not halt. A simple solution most people would rely on is to run the code to check if it halts or not. Unfortunately for us, it is not as simple as that. This particular topic has so many mysteries that are need to be solved that even expert programmers have been baffled in trying to prove if a code will halt at every input or loop infinitely. It shows that it is almost impossible for all problems to be solved with algorithmic developments (not computable).Wow! I think that I am having a speechless moment right now. How wonderful! The almighty computer cannot solve all our problems, I concur that we are doomed!
This is the collatz code that was presented to us in the lecture slides. The problem here is that it quite difficult to prove that this code would not loop forever. How this code works is that it stops at every natural number. The question is how far would it go? If only I knew the answer, then world would be at peace.
def collatz(n) :
      while n > 1 :
            if n % 2 == 0:
                   n = n / 2
           else:
                  n = 3*n + 1
return "Reached 1…”
Secondly, I do not get how infinity does not equal infinity? I always knew math was strange.

If we could only halt like Keanu Reeves, then problem solved !
                           

Linear Searching

In this slog we shall talk about counting steps and worst case scenarios for Big-Oh. This is the topic in which we have to actually understand how each line in python works. This particular topic was quite difficult for me to understand in the lectures. I had trouble grasping the concept of which lines have to be executed one after the next. However, Madina, my TA, made it a bit easier for me to understand this particular topic.

We were presented with this question for the quiz.

This was the code given to us for sum_up
   
def sum_up (n): 
    i = 0
    s = 0
    while i < n:
        j = i
        while j>= 0:
            s = s + 1
            j = j - 1
        i = i + 1
    return s

At first I had no idea really how to start with this question. However, I tried to remember the steps Madina showed us in how to read and understand each line. The first question was, what do sum_up(0), sum_up(1) and sum_up(2) return?

For sum_up (0), it returns 0
For sum_up (1), it returns 1
For sum_up (2), it returns 3

The general expression for what sum_up (n) returns is (n (n+1))/2

We were required to write steps to explain our thinking.
The outer while loop iterates i < n for the values i = 0 …..n = n-1 and the inner while loop iterates for values j = i ……0. Thereby, s would keep going through the sums on each of the iterations once it is satisfied.

Therefore n-1
                   Σ     (i  + 1) = (n(n + 1))/2

               i < n
I have also browsed through many different slogs in which I though all of them were so unique filled with so many great ideas, creativity and interpretations in problem solving for this course. However, I found one that stood out impeccably for me. Take a look!

http://www.soohamrafizslog165.blogspot.ca/

Week Nine Stresses

Welcome fellow CSC165 bloggers or sloggers! Week nine was crazy, assignment 2 was due and then a term test 2 the next day. This is university life; I have to keep reminding myself. Assignment 2 was quite a struggle I must say. Luckily we have fellow group members to share these struggles. The assignment that we were given was to prove or disprove proofs. Some of them were quite obvious to determine whether they were true or false.  I believe it was question 1.2 that took days to solve. My group members and I felt as if all hope was lost, that we were slowly dying inside. Giving up was a plan but that “function”was never executed, thankfully.


Proving a statement I realize, takes absolute dedication. It is something that takes a lot of practice and patience. Each of us in our group gave our own ideas and ways how to tackle and solve the proof. Once we submitted assignment 2, it was like a breath of relief (exhales). However, the stress did not stop there, midterm test time the next day. On the bright side, after doing all those proofs for assignment 2, we would have had proofs literally stuck in our heads. I was confident that I understood most of proving statements until the exam “proved” me wrong. However, I was pretty sure I did better in this test than the first one, I hope. Good luck to everyone and have a great week!