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!

Sunday, 26 October 2014

Penny Piles Problem

The daily lives for computer scientists are to create solutions to problems. The name of our problem that we were presented in class was called “Penny Piles”. My understanding of the problem is that the left draw contains 64 pennies and the right draw contains 0 pennies. Thereby, the goal was to arrive at 48 pennies in one draw. However, there were two rules in which we were given and they included:
        
          a) If the left draw has an even number of pennies, half of them can be transferred to the right draw. If     the left draw ends up with an odd number of pennies then operation l is disallowed.

b)   If the right draw has an even number of pennies, half of them can be transferred to the left draw.If      the right draw ends up with an odd number of pennies then operation r is disallowed.

I worked with one of my friends to tackle this problem since we were suggested to do so.  We started with the 64 pennies in the right draw and 0 in the left. We divided 64 by 2 since it was even and got 32 pennies to transfer to the left draw. This resulted in both draws having 32 pennies. We divided 32 by 2 once again and transferred the 16 pennies into the right draw. This resulted in 48 pennies in the right draw and 16 in the left. We repeated this method until we arrived at odd numbers of pennies in both draws, 63 in the right and 1 in the left draw. Even though we arrived at the desired 48 pennies in one draw at the beginning, the problem was not totally solved.

We tried different numbers in the range [0,64] in which all of them seemed to work. We tried the different numbers on both sides and we concluded that it did not matter which side we started from the left or the right because we arrived at the same answer. If you notice the algorithm, l(left draw) + r(right draw) = 64(total number of pennies)




Comment on how your solutions were like! Have a great week!

Introduction to Proof Structure

Welcome to the world of proofs! This week, we were introduced to the structure of how to compose a proof. We are given a statement and required to write a specific step by step structure that demonstrates how we are supposed to carry about writing the proof itself. Comments were also required to show that you have understanding of the claims that you are making in the proof.

Below, I will demonstrate with an example on how a proof structure is to be written for this course with a few additional comments.
             
(for all)x E R, (for all)y E R, x<y => (there exists)z E R, x<z and z<y

Assume x E R, y E R   # this is the domain assumption (can only be made for universal quantifiers)
     
   Assume x < y # antecedent
      
      Let z’ …… # since the value of z has not been determined yet, it is z prime.
                       # this assumption depends on the values of x and y.
     [proof of z’ E R]
   
     Then z’ E R # this is written once this statement is actually proven
   
     [proof of x<z’ and z’ < y]
    
     Then x < z’ and z’ < y
   
     Then (there exists) z E R, x < z and z< y # introduce (there exists symbol)

     Then x < y => ex z’ E R # intro =>(implication)

Then (for all)x E R, (for all)y E R, x < y => (there exists)z E R, x<z and z<y #intro (for all)

Midterm Examination Day

We had our first midterm test for this course and my first midterm test overall in my university career so far. I could not have been more nervous because it felt as if it was a matter of life or death at that point. I literally saw the tension and pure anticipation pasted on everyone`s faces while awaiting entry into the examination room. The examination room itself was intimidating due to the vastness of the room. What caught my eye was seeing the “infinite” rows of desks placed so neatly that it seemed as if it was not even an inch out of place. Now for sure I accepted the fact that I am not in high school anymore.

Having the midterm test placed in front of me waiting to be opened, was the most anticipating feeling because everyone wants to know if the material inside would make us or break us. Once I opened the booklet, the structure of the test was almost identical to the sample test we were given before the midterm. I was happy at first and then realized that I should have just written the sample test as my cheat sheet. As I was going through the first question, I definitely had an idea how to tackle the question since I studied the sample test.

Unfortunately for me, I had moments of self-doubt and changed my answers in which I believe was the biggest mistake I made. From assignment 1, I had learnt a lot but I allowed my nerves to get the best of me after a long time of writing examinations. However, I have learnt from this experience by understanding that there will be moments of self-doubt in examinations sometimes, but learn to have confidence in the materials you have studied. Yes, I am disappointed in myself, however, I know that there will be other opportunities in this course in which I can make up for my lost marks.

Share your exam experience and comment below!

The Blood, Sweat and Tears of Assignment 1!


Can you imagine that more than three weeks have passed already since we have started university? This third week was very significant because we were presented with our very first assignment in CSC165. I must say that many of us have put in a lot of blood, sweat and tears in completing Assignment 1. This was an extremely productive as well as a thinking based assignment which required my group and me to apply all the material that was covered in the lectures so far.  Some of the questions were quite straightforward as they were more “warm up” questions to prepare for the more challenging ones. We each had our own individual interpretations for some of the more challenging questions such as numbers 3 and 5.

We had some trouble with those two questions in particular because it relied heavily on how you interpret what it was asking as well as identifying all the possible scenarios. Some of the questions I had problems understanding how to write in symbol form because it turned out to be more complex than I personally anticipated. However, with the avid support systems and teamwork provided by my teammates, we were able to each contribute in our own ways for each of the questions. We in-cooperated each other’s ideas and asked questions when we did not understand one another’s way of thinking.

Additionally, there were times we felt like giving up, however, we made a conscious decision to keep trying and produce the best possible answers that we could develop. Through this experience, I was able to understand much more of the topics than before by working with other students with varying thought processes and strengths. I really hope that our hard work paid off and everyone else`s as well in this course.

What are your thoughts on assignment 1?


Comment below!

Saturday, 27 September 2014

Let Us Fold Paper!

Welcome back fellow CSC165 classmates to my second blog! As you have noticed, time has passed by so quickly. Can you imagine that we have completed three weeks of classes? I wonder if everyone has started preparations for mid-term exams. Sadly for us students, exams are right around the corner. Stress! I have come to a legitimate conclusion that work never comes to an end at university!

Now let us talk about what is really important here, CSC165. This course never ceases to amaze me each and every time. It is filled with the type of logic that has never even entered my mind before. Take for instance, the logic behind obtaining the pattern for folding a strip of paper. Sounds simple right? In my opinion it was mind boggling because it required individuals to use their level of observation as well as mathematical logic. I would have never thought in a million years about finding the pattern that was created after folding something so simple as piece of paper.

For this exercise we were required to understand the problem that was presented; construct a plan, then proceed to execute it and report the pattern observed. We got into pairs and each came up with unique ideas to solve the up and down sequence for four folds. Some students tabulated their results in a two columned table with “Number of Folds” on one side and “Pattern” on the other. Some students used the up and down arrows to demonstrate the pattern while some actually drew out the pattern to predict each sequence.

Through this exercise in class on Friday 26th September, I am convinced that Computer Scientists are more than just individuals who sit near a computer and write code all day. They are the logical thinkers who solve both simple and difficult problems in a sequential manner in which can make life so much more organized.

What are your thoughts on the paper folding exercise?

Comment below!

Friday, 19 September 2014

Wake Up It Is CSC165!

Welcome everyone to my newly established weekly blog on Mathematical Expressions and Reasoning! To make this course sound even more high tech as soon to be Computer Scientists should do, we must include numbers. So let`s try that again, welcome fellow bloggers and TA`s to the CSC165 blog!

What a two weeks it has been especially for us first years! Hustling and bustling to get to class, feeling like a speck in classes filled with hundreds of students while feeling absolutely dumbfounded when the professors take their articulate speaking to a whole new level.

CSC165 is quite different from the introduction to programming course (CSC108) in that it actually requires you to think outside the box; logically and smartly. It is one of those courses which can tie your brain in knots if you do not understand the language used. On the other hand CSC108 is a more straightforward and hands on course.

We now arrive at the dreaded Sets! Sets! Sets! The topic that I have not done in six years and never really knew its application until a full two weeks of it in CSC165. The first week was basically determining whether a claim was true or false about sets. In other words this is known as quantification. In order to prove quantified claims as true or false we should take into consideration two main things:
     1. In order to prove a universal claim as true, there should be no counter examples.
     2.  In order to prove a universal claim as false, at least one counter example should be identified.

Now on to the famous interconnected topics of Implication, Converse and Contrapositive which were all touched on in both weeks 1 and 2. These topics in particular completely baffled my mind because they are unlike anything that I have done before. You would think by doing Computer Science, you would relieve yourself from English, but boy I was wrong! If I have to describe these topics, I would refer to them as a form of twisted logic. In order to express implication, P must imply Q.

For example if you have this sentence: If you do your homework, you will pass all your exams.

The implication for this sentence is: If you do your homework (P), you will pass all your exams (Q).

The converse of this sentence is: If you passed all your exams (Q), you did your homework (P).

The contrapositive of this sentence is: If you did not pass all your exams (if not Q), you did not do your homework (then not P).

What were your experiences like for the two weeks in CSC165 so far?
Comment  below!