Sunday 29 March 2015

Week 11: That was then, and this is now

Before I do a CSC148 rewind, I have a quick and happy announcement to make. The strike is finally over! Phew! Everything can get marked now!


Aside from the strike (and missing a month's worth of quizzes), it's been a crazy ten weeks. All that's left is to (hopefully) bring up my mark in Assignment 3 and the final exam. 

What I loved about A3 was that there were two options for students to choose from: the harder (minimax) option or the easier option. My group opted for the latter option. I found it extremely generous, given that my partner and I did not work our minimax the way it should be last time. 

I've been re-reading my previous SLOG posts numerous times. Here, I try to explain concepts from the previous week for myself and for other people. That way, I can increase my understanding a bit, but it doesn't imply that my head hasn't stopped spinning completely. I understand recursion a bit better now that I've seen it numerous times, but there's still room for improvement. I want to take my understanding to the next level. In other words, I want to try and become a recursion master!

I am, however, pleased to say that my writing keeps getting better each time I write a SLOG entry. As I said before, a SLOG is a good way to practice writing. There is a justification that writing is an essential skill that geeks must have; writing is a form of expression. Also, there's a good reason CS students need to take CSC165. A significant part of the course deals with mathematical expression, which includes Big-O. We do tons of writing in that course, except not completely with Python. We practice things such as proof writing and logical notation. It may be hard at first, but with repetition and proper guidance, it will all be better. 

As well, when I was working on assignments and labs, I wrote comments to help me further understand how the code works. This person speaks about adding comments in Python. They can definitely be helpful when it's time to review.

The course setup somewhat reminds me of CSC108 such that we receive weekly worksheets as in-class exercises for mastery of the upcoming concept. We take these worksheets up after a couple of seconds or minutes, depending on how much time Prof. Heap allots to us. They are used to train us in the art of reading and writing code on paper, which I struggled with greatly in the CSC108 midterm and exam. Nevertheless, help is there when I need it. 

Comparing my experience to Saima's, I, too, understand things at a conceptual level rather than at a practical level (implementing code). Before the exam, I'll keep doing what I'm doing, which is reaching out for help whenever possible and not having too much anxiety. 

I do try to ask questions and practice the concepts, but I need to catch up on the labs because I haven't worked on them due to assignments from other courses. 

Well, we're almost there. I swear we started CSC148 yesterday. My group will complete A3 and I will begin reviewing for my exams. 

Best of luck in the final moments of CSC148, everyone! We can do this!

Last, but not least, here's a positive photo.

Sunday 22 March 2015

Week 10: I will find you, but I won't kill you

The strike has been going on for three weeks. Thus, we have not had labs or quizzes for the past three weeks. They are worth 10% of everyone's final CSC148 grade. My TA was quite helpful with the lab exercises because I could not do the labs on my own. I still can't do them on my own. While the strike has been going on, I started turning to Piazza or office hours to ask questions. Nevertheless, Professors Heap and Horton have been doing a great job with managing the course, office hours, and Piazza discussions while the TAs are gone, so hats off to them!



In this post, I am going to talk about mutating binary search trees using recursive functions insert() and delete() in class BTNode.

All of the following conditions must be present for a tree to be classified as a binary search tree:
  1. All data are comparable.
  2. Data in the left subtree are less than root.data.
  3. Data in the right subtree are greater than root.data.
Here is a visual representation of a binary search tree.



I found the lecture on mutating BSTs straightforward to follow. In the additional exercises for Lab 6, the insert function can be found, and the code implementation is based off the general formula for recursion: base case, then general case.

To implement insert, we need an accumulator variable as our return value. Next, we start with the base case: if the node is a root, we create a leaf using a variable. Then we look at conditions 2 and 3 from above. If the data in the left subtree are less than root.data, recursively insert new data in the left subtree. On the contrary, if the data in the right subtree are greater than root.data, recursively insert new data in the right subtree. Finally, return the accumulator variable.

As for the delete function, we looked at an algorithm to help us implement it together in lecture. It is very similar to the algorithm for insert, except we recursively remove data in either the left or right subtrees in this case. However, there are a few extra steps. 

"I'm overwhelmed already," I think to myself as I attempt to understand how it works.
If a node with data has less than two children, acknowledging that one of the children is None, return the other child. Finally, if a node with data has two children that are not None, then replace that data with the largest child in the left subtree. Delete the original data that was swapped with the new data, and then return the new data.

I'm definitely going to practice with these two functions in Lab #8 while balancing work from my other courses.

This is the code that Prof. Heap showed us and had us work with.

I wish everyone the best of luck in A3 and the rest of the course! It's not easy, but it's not impossible! I'll leave you all with some motivation because positivity is key.


Saturday 14 March 2015

Week 9: A conga line, but with nodes

This is a conga line. It gave me the inspiration for the title of this post.

Except nodes don't dance.

Oh, great. Now this song is stuck in my head:



In all seriousness, though, how did we just finish Week 9? Didn't the semester start yesterday?

Exactly.

Anyway, we only had one lecture on mutating binary search trees. Prof. Heap suggested that I add things such as definitions and important lines of code onto my aid sheet. In addition to these, I drew an example of a binary tree and a linked list. I was able to finish in fifty minutes, though more time would be helpful for students to look over their answers for errors, big or small, before submitting their tests.

What I have learned not to do in test situations is aim for a specific mark, say, 100. (I'm not a robot.) This would lead to mental stress, which I have endured a lot when I was around sixteen in grade eleven because of my heightened fear of failure. In spite of U of T, my fear of failure has been reduced slightly from grade eleven. So, Wednesday's test was fair. I was able to stay calm while writing my test.

We've covered linked lists in the past week. (The conga line above may give you a little hint.) A linked list can be defined in two ways:

  1. Lists comprised of an item and a sub-list
  2. Objects, or nodes, that contain a value and refer to the next node in a sequence
According to Prof. Horton, in CSC148, we will look at the second definition of linked lists. I find her slides useful to help me build on my understanding of concepts. They can also be useful for students in all lecture sections. 

Here is how one would visually represent a linked list. (Yay, visuals!)


15 is at the front of the list, and 4 is at the back. We use an "X" to indicate that we've reached the end of the list. In the case of the conga line, arrows point to the next node in the sequence, much like how people link arms with whoever is next in line.

With linked lists, we worked with two classes instead of one: LLNode and LinkedList. Hence, we were taught that a wrapper class represents a linked list in its entirety. So, LinkedList is our wrapper class. (LLNode refers to one node.)

I was extremely confused about this concept, but after looking at lecture slides from both profs and a post on Piazza, I understood how wrapper classes worked.

Speaking of which, Prof. Heap gave my class a gentle reminder not to confuse "wrapper" with "rapper."

404: "rapper class" not found

We also looked at a code generalization when it comes to traversing a linked list. It goes something like this. I've also added comments to help understand what the code does.

cur_node = self.front # start at front of list
while <some condition here>:
     <do something here>
     cur_node = cur_node.nxt # move on to next list
     # end of list: while loop condition becomes False
     # loop exits

For more on linked lists, go here for the Python representation of linked lists.

Also, we did not have labs for the past two weeks due to the TA strike; the profs left us to do the labs ourselves and ask for help when needed. I'll work on Lab #8 soon.

Happy Pi Day, everyone! In celebration of this day, have a picture of a pi(e).


I'll be back for more CSC148 ramblings next week. Stay tuned, and all the best on the last few weeks of school!

Saturday 7 March 2015

Week 8: I'm a tree hugger

To start this blog post off, I must say that the past two weeks have been really hard. In particular, I devoted most of my time to Assignment #2 with my partner this past week, which means that I now need to catch up on this week's lab and review previous labs and lecture notes to prepare for the test. Go here if you need some help with the additional exercises.

We did our best on that assignment. The second test is on Wednesday, and I hope it's better than the first. I didn't do well on the recursion part of the first test, which cost me marks. (It's March now. Where are my time management skills?) Otherwise, I would have gotten at least a B+, which was the class average. Nevertheless, that class average was fantastic, especially for a first year computer science course like CSC148! Kudos to everyone! (Note to self: I CAN and WILL do well on the second test!)

Here's a good calm-down routine for the test. This is surely what I will be using, too:



Like everyone else, I have work from other courses to do. (Saima, I am in the same boat as you. Let's work hard.) As Saima put it in her post, time management is key, and I mean very key. It's short, sweet, and to the point. Not to mention, it's motivational! I recommend reading her blog, too, because she reflects on her experience in CSC148 very well.

Another fellow CSC148er gave me some advice recently. They told me to be curious as well as not be satisfied with not understanding anything. I need to be able to understand why my code works the way it does. One thing to think about when I'm in my Thursday morning lab is to find out why the method that I implemented works the way it does, with support from my TA. My problem solving skills will improve if I engage with the material as thoroughly as I can. The nicest part about this course and CSC165 is that an aid sheet is allowed.

Anyway, here's the latest from the CSC148 world. We've been looking at binary trees. (And I've been struggling with CSC148 as usual.)

"Binary trees? You mean these?"
As a bit of review from recursion, a tree is a data structure that consists of nodes. Some of these nodes have edges, which connect one node with another. So, it looks something like this:

Now, a binary tree is a type of tree that consists of a "parent" node with two "children," named left and right. Prof. Heap showed us a class, BTNode, that represented a binary tree. The above diagram is an example of a binary tree with 2 as the parent and 7 and 5 as the children. Then it goes on.. and on... and on.

I'm going to familiarize myself a bit more with binary trees in time for the test. The advice that someone gave me can be really helpful for me and anyone else who is struggling with grasping CSC148 material.

Best of luck on the test, everyone! I'll see you next time!