Friday, 27 March 2015
Week 11
Reading my previous posts, I have seen that I had great trouble with Recursion. Now that I have done many exercises dealing with recursion, I feel pretty comfortable with them as we have done so many functions in Assignments 2 and 3 that it's coming naturally when you're trying to implement a recursion method.
Also, Linked Lists now aren't so bad. I think the trick is to continue doing exercises until you get the hang of it and start gaining comfortability dealing with these sets of problems. Anyway that's all I could really write about this week and everything else has been going pretty well.
Other news, the STRIKE IS FINALLY OVER. I don't know how the strike ending the week before school's done is going to affect our marking scheme but I feel like all of my courses have been on a rocking boat and swaying in so many directions that I don't even know what will happen. Im just hoping for the best because I really want to get the most out of my tuition fee and I feel like I did not get that this year. But hey! Welcome back TAs, I have missed you! I have now come to realize how much Computer Science courses rely on labs and tutorials to understanding and apply the concepts we've learned. I hope this doesn't happen again in the near future. It's really a struggle.
Thursday, 19 March 2015
Test Numero Dos
Week 9 has been a hectic week due to having a test in both CSC165 and CSC148 and the lack of TA support. Regarding the strike, I wish it was over since most of my knowledge of concepts and problem solving are cleared up during Tutorials and Lab Exercises. So, going to the two tests were filled with uncertainty with a lack of confidence of knowing these concepts. A lot more work had to be put into studying as self teaching was the key to get by this week and tests which greatly put me behind in other courses but hey! You have to do what you have to do and balance all of your courses.
Anyway, the test was not too bad. It was pretty straight forward and it's everything that we've seen before in class for sure. I noticed that I had made a mistake in the first question when they ask what is the biggest height a binary search tree could have with 20 nodes. To my understanding, I thought that each node had an arity of 2 which made me think that it had to either have no children or 2 children so I did not think of the possibility of the tree to be just one long path of 20 nodes. But now I am aware of my mistake and this possibility.
The recursion part was alright, It was to only list the even nodes in the tree from a certain interval if I remember correctly. So if the node was in the interval, you'd have to check the left tree and right tree and so on and create an if statement that only returns that node if " n % 2 == 0".
The linked list part of this test was some what challenging. But the handy dandy cheat sheet really came clutch (Urban Dictionary: the crucial moment that comes between winning and losing)! But obviously I was winning (maybe not, we'll see) because the code was pretty similar to the lab07 exercise when "delete_after" had to be implemented, if I'm not mistaken. You just had to manipulate the code a bit to get it to check the right conditions and to add the value of the next node to the current one then skip it. Just some minor changes to that code and bam you got it. If it isn't right...... well then.... part marks, am I right? Hahaha.
Overall, not such a bad test, we'll see about that though. Anyway, the last few weeks and the final push with no TA support to get through this semester and I am...... feeling...... indifferent about it. Like I want to finish the semester already and we're so close to the finish line but with no TA support, I don't know if i'll make it there, especially with no TA help with A3 and as the exam approaches to clear any misunderstandings and concept confusion with labs. But we got this! Work hard, Program Hard! :)
Anyway, the test was not too bad. It was pretty straight forward and it's everything that we've seen before in class for sure. I noticed that I had made a mistake in the first question when they ask what is the biggest height a binary search tree could have with 20 nodes. To my understanding, I thought that each node had an arity of 2 which made me think that it had to either have no children or 2 children so I did not think of the possibility of the tree to be just one long path of 20 nodes. But now I am aware of my mistake and this possibility.
The recursion part was alright, It was to only list the even nodes in the tree from a certain interval if I remember correctly. So if the node was in the interval, you'd have to check the left tree and right tree and so on and create an if statement that only returns that node if " n % 2 == 0".
The linked list part of this test was some what challenging. But the handy dandy cheat sheet really came clutch (Urban Dictionary: the crucial moment that comes between winning and losing)! But obviously I was winning (maybe not, we'll see) because the code was pretty similar to the lab07 exercise when "delete_after" had to be implemented, if I'm not mistaken. You just had to manipulate the code a bit to get it to check the right conditions and to add the value of the next node to the current one then skip it. Just some minor changes to that code and bam you got it. If it isn't right...... well then.... part marks, am I right? Hahaha.
Overall, not such a bad test, we'll see about that though. Anyway, the last few weeks and the final push with no TA support to get through this semester and I am...... feeling...... indifferent about it. Like I want to finish the semester already and we're so close to the finish line but with no TA support, I don't know if i'll make it there, especially with no TA help with A3 and as the exam approaches to clear any misunderstandings and concept confusion with labs. But we got this! Work hard, Program Hard! :)
Saturday, 14 March 2015
Linked Lists
Hello there once again Sloggers! Can't believe we're already more than half way done this Winter semester, let alone 1st year! Almost there guys, the final push!
So Week 9 talks about Linked Lists! To be honest, this concept was some what confusing to me at first and watching this video really helped me grasp the concept.
So basically the most typical structure of Linked Lists code goes somewhat like:
So Week 9 talks about Linked Lists! To be honest, this concept was some what confusing to me at first and watching this video really helped me grasp the concept.
So basically the most typical structure of Linked Lists code goes somewhat like:
cur_node = self.front #This is to set a variable to the first node in the list while <some condition here>: #Depends on the problem
cur_node = cur_node.nxt #Update the node to the next one
I think of it as a normal list but instead of looping through a list automatically, you have to keep updating the node that you want to check and if it satisfies the condition given. Also, you have to take into consideration when the list is empty, or when the you reach the end of the list or if the next node is None, or if it's size is 0, and make "if statements" that satisfy those conditons based on your method accordingly.
We had a lab to do for this concept but unfortunately, without TAs was proven to be very difficult because we didn't have the extra guide to lead us to the right direction especially that it is a new concept. But overall, the lab was not too bad but I still need to practice cases where if the loop reaches the end or if there aren't anything in the list because I tend to miss some important things in my code that will make it run incorrectly. More practice needs to be done with these methods but other than that, not too bad to get my mind around.
Sunday, 8 March 2015
Week 8 - Trees and Binary Trees
This week we've been taught how to create trees and binary trees. Trees look something like this:
Trees are a set of nodes with directed edges between pairs of nodes. An edge connects a parent node to a child node. The node at the very top is called the Root Node which is the one node that does not have a parent in the tree. The parent node is a node that contains children. Also the length of the path is the number of edges in the path of the tree.
These are some more useful terminology that is helpful for the structure of trees:
- A leaf is a node with no children (such as #1, 4, 7, 10 in the diagram)
- Internal node is a node with one or more children (#5, 3, 8 in the diagram)
- Subtree is a tree formed by any node and its descendants and the edges connecting them
- Height of the tree is the maximum path length + 1
- Depth is the height of the whole tree minus the height of the tree rooted at that node
- Arity or branching factor is the maximum number of children for any node
We were also introduced to a specific kind of tree which is called the Binary Tree which looks like:
Distinctive factors that make the binary tree special is that..
- Binary Trees is a tree with branching factor of 2. Which means that each node has a maximum number of 2 children.
- The children in a binary tree are called left and right child
- Binary Search Trees have a specific property which is that for evener node, its value is greater than all values in its left subtree and less than all values in its right subtree.
- It's good to note that each subtree as well is a BST.
- For example, in the diagram above, all of the nodes on the left child side of 68 will always be less than the nodes values on the right child side of 68 and the pattern still continues as you keep going down the subtree. For example, look at the bottom of the subtree of the node 11. -22 is less than 2 which means the left side is always less than the right side.
Through out the labs, we have worked on some recursive methods that calls on trees that gets a better idea of how they work. Here's an example:
(Will insert pictures later when I get on my CDF account)
You can note that the base case is mostly when there is no children (if self.left == None and self.right == None) which always occurs at the very bottom of the tree.
I think I still need to review this concept as its difficult to wrap my head around but doing the labs really do help practising the concept lectured in class. I really hope the TA strike comes to an end soon as it's my main source of understanding computer science concepts better and its where everything starts to make sense with my TAs help even for CSC165... but other than that, ill try my best to understand it on my own and will try my best on the next test...............ha ha... anyway Happy Slogging and good luck on Test 2 everyone! :)
Subscribe to:
Posts (Atom)