Monday, 29 October 2012

Computer Hardware

This week in CSC104 I was confronted with the realization that I have lost all previous knowledge I ever had of computer hardware. Bus? ALU? Compact discs??? This sounds like a job for good ol' Wikipedia.

Time to review some definitions:

http://en.wikipedia.org/wiki/Arithmetic_logic_unit
http://en.wikipedia.org/wiki/Bus_%28computing%29
http://en.wikipedia.org/wiki/Von_Neumann_architecture


I also discovered that Professor Heap posts additional notes on the CSC website. They are extremely helpful for anyone else who is looking for further clarification!

http://www.cdf.toronto.edu/~heap/104/F12/Lectures/W7/hardware.html


Friday, 19 October 2012

Paper Folding Algorithm

This week in CSC104, we were given the task of formulating an algorithm that could predict the direction of the vertices from folding in a strip of paper. The instructions were to "Take a strip of paper and stretch it so that you have one end between your left thumb and index finger and the other between your right thumb and fore finger. Fold the strip so that the left end is on top of the right end. Repeat this several times, each time folding so that the left end is on top of the right end of the strip." The assignment asked to find a sure way to predict the sequence of ups and downs for any number of times you fold the paper.

UNDERSTANDING THE PROBLEM
We want to be able to predict future sequences when the thin strip of paper is folded any number of times.
To further understand the problem, I conducted trials for a strip of paper with up to 5 folds. Their patterns and characteristics are listed below (Tables 1 and 2).

DEVISING A PLAN
A few observations:
-       The number of segments (bordered by the paper edges and vertices) is 2F.
o   S = 2F
-       The total number of vertices is one less than the number of segments.
o   V = 2F-1
-       The number of down vertices is 2(F-1).
o   D = 2(F-1)
-       The number of up vertices increases by 2(F-2) with each successive fold.
o   UF = UF-1 + 2(F-2)
-       The number of up vertices is also 1 less than the number of down vertices.
o   U = D - 1
-       Each fold has a central D.
-       For F number of folds, the sequence of F - 1 forms the right portion of F’s sequence after the central D.
o   For example, with 2 folds, the resulting sequence is UDD. For 3 folds, the resulting sequence is UUDDUDD. The UDD from the sequence before is carried over into the next, forming the right side of the sequence.
-       The left side of the central D is a toggled mirror image of the right side.
o   For example, UUDDUDD has a right side of UDD. Toggling it will replace D’s with U’s and U’s with D’s. Therefore, UDD becomes DUU. Flipped in a mirror image, it will then be UUD. Put together, you have UUDDUDD.


CARRYING OUT THE PLAN
We can now test out this method to determine the sequence of 6 folds, given the sequence for 5 folds!

1.     Carry previous sequence over to right side of central D of target sequence.

DUUDUUDDUUUDDUDDDUUDUUDDDUUDDUDD

2.     Toggle mirror image that sequence!

UUDUUDDUUUDDUDDUUUDUUDDDUUDDUDD

3.     Put it all together!

UUDUUDDUUUDDUDDUUUDUUDDDUUDDUDDDUUDUUDDUUUDDUDDDUUDUUDDDUUDDUDD

LOOKING BACK

We can double-check our prediction with our expected characteristics:
Total # of vertices = 26 – 1 = 64 – 1 = 63 = true!
Total # of downs = 26-1 = 25 = 32 = true!
Totally # of ups = 32 – 1 = 31 = true!

The sequence fits all the criteria as the previous sequences did!
And there you have the sequence for 6 folds!

Saturday, 13 October 2012

Boolean Logic

As a Human Biology major with a not-so-strong computers background, the thought of taking a Computer Science course was somewhat intimidating. So far in this course (CSC104 - The How and Why of Computing), I have faced multiple challenges, especially in the programming portions. However, the one lecture topic that had really confused me was Boolean Logic.

"True or false is true and true and false is false."







But why?

To me, "true or false" meant that the answer could be either "true" or "false"- why would it automatically be true? I guess you could say I found Boolean logic to be very illogical, and when you throw NANDs and NORs into the equation it just makes everything even worse.
After hours of reading and re-reading Wikipedia and still not understanding anything, I turned to my TA for help. Amazingly, he was able to explain the whole thing to me in under 15 minutes. I realized the statements were not as horrible as I had originally envisioned them and they were in fact, pretty easy to solve. After that, I was quite pleased to see Boolean logic on the midterm!