This difficult semester has finally come to an end. The strike took a fair bit my patiences. With all the classes being cancelled and the lack of TAs, there was a lot of confusion about assignments and tests.
We got our tests back and I am very happy with my mark. I'm very excited for the exam because I really feel like I will do well. I want a Computer Science Major so I'm glad I got the marks that I got. I think this course was very important for my future in computer science. It taught me more about Python as a language, different methods and even different types of data structures. I didn't have many hurdles in this course other than the strike. I had friends in upper years help me understand concepts and this made the course even easier.
My favourite concepts were recursion and tree traversals. Traversals were the most fun because solving what will be printed from a given tree is kind of like a puzzle and I love puzzles.
I think the best part about this course is the marking scheme. It is tailored to give each individual person the best mark possible. This is important for anyone looking to do a POST in computer science.
I also really loved Danny as my professor. He was very clear in his explanation of the concepts. I appreciated his willingness to be available through the hard times of the strike. He was also very wary of being fair to every individual who has taken the course in both this semester and last.
Overall, I am very happy with how things ended up this year. I am grateful for the opportunity to have been taught these concepts.
Thanks for a great semester!
Sunday, 5 April 2015
Sunday, 29 March 2015
Looking back on recursion
Looking back on recursion, I'd say I still pretty much agree with what I had discussed previously. Something I didn't quite get the grasp of was the idea that every time you enter a new 'node', it is a new recursive call. For example, if you are trying to recursively go through a tree, every time you enter a new node, you temporarily leave the previous recursive call and enter a new one and rerun that function.
For example, if were to recursively go through this tree inorder, we start at 2. Inorder says we must look at the left subtree, the root and then itself. So starting at 2, we enter the left subtree which is 7. This just opened a new recursive call. We're not going to go back to 2. We're going to go to the left again. This 2 opens a new recursive call and since 2 has no left, we return 2 and since it has no right children, we return to 7 and return that. Then we enter the right subtree and repeat the process. In the end, the answer should be: 2, 7, 5, 6, 11, 2, 5, 4, 9.
I have commented on a few slogs for this particular topic:
These sloggers for the most part had the same ideas as I did when it came to recursion. In its most basic form, recursion is simply when a function calls itself within its own function but it is important to have a base case or we will have an infinity loop.
I also liked the way these sloggers approached problems. one went to another website for more information and others just worked with it over and over again until they understood.
I think what most people had issues with was the strike. It was really hard to get the help we really needed but I believe most of us pulled through.
For example, if were to recursively go through this tree inorder, we start at 2. Inorder says we must look at the left subtree, the root and then itself. So starting at 2, we enter the left subtree which is 7. This just opened a new recursive call. We're not going to go back to 2. We're going to go to the left again. This 2 opens a new recursive call and since 2 has no left, we return 2 and since it has no right children, we return to 7 and return that. Then we enter the right subtree and repeat the process. In the end, the answer should be: 2, 7, 5, 6, 11, 2, 5, 4, 9.
I have commented on a few slogs for this particular topic:
- http://csc148justinsong.blogspot.ca/2015/02/week-7-summary-of-recursion.html
- http://nailedcsc148.blogspot.ca/2015/02/impressions-of-tracing-recursion.html
- https://colslog.wordpress.com/2015/02/08/recursion/
These sloggers for the most part had the same ideas as I did when it came to recursion. In its most basic form, recursion is simply when a function calls itself within its own function but it is important to have a base case or we will have an infinity loop.
I also liked the way these sloggers approached problems. one went to another website for more information and others just worked with it over and over again until they understood.
I think what most people had issues with was the strike. It was really hard to get the help we really needed but I believe most of us pulled through.
Sunday, 22 March 2015
My impressions of week 9
We had a midterm this week and it was definitely a lot to handle with the strike. Studying for the midterm was all about drawing. I drew trees and tried different transversals and recursion methods. I also drew pictures for how to work out linked lists.
We learned how to delete nodes from a BST. This is a very tedious process because there are so many conditions one much consider. If you wish to delete a node, you have to be wary of what node will take its place. Since a BST has the condition where the left child is smaller and the right child is bigger, we would want to make sure that whatever we remove, the replacing node still fulfills the conditions that the left child is smaller and the right child is bigger.
Working on the lab was difficult. I didn't fully know how to work on the delete method but my problem was my understanding of delete. I kept forgetting that we have to be aware of what we are removing. We have to careful if we want to remove something in the middle because the whole tree could collapse. It's like a terrible game of Janga.
Other than these things, my week was really good. I'm really enjoying the course thus far and I am very glad I have taken this course.
We learned how to delete nodes from a BST. This is a very tedious process because there are so many conditions one much consider. If you wish to delete a node, you have to be wary of what node will take its place. Since a BST has the condition where the left child is smaller and the right child is bigger, we would want to make sure that whatever we remove, the replacing node still fulfills the conditions that the left child is smaller and the right child is bigger.
Working on the lab was difficult. I didn't fully know how to work on the delete method but my problem was my understanding of delete. I kept forgetting that we have to be aware of what we are removing. We have to careful if we want to remove something in the middle because the whole tree could collapse. It's like a terrible game of Janga.
Other than these things, my week was really good. I'm really enjoying the course thus far and I am very glad I have taken this course.
Sunday, 15 March 2015
Linked Lists
This week, we learned about linked lists. This was a little hard for me to grasp. After class, I had to review it with a friend until I understood it. The part I had issues understanding was that every value has to be a node first. That is why we have to store it as an LLnode class. Then we have the wrapper class that can put them together. Linked lists have a front, a back and a size. Each node in the list references another node. It's kind of like a line. The front points to another node, which points to a new node until a node points to the back.
When adding something to the back of the linked list, one must first make the value into a new LLnode. Then, it is important to change the current back so it is pointing to this new node and then set this new node to back. I made the mistake of thinking that we first change the new back to he new node and then change the old back to point to this node. If it was done this way, we would have lost the reference to the old back. Then after all of this hard work, we have to add one to the size of the linked list.
Drawing pictures for these linked lists helped me very much. I was able to visualize exactly where things needed to go and how they should be coded.
When adding something to the back of the linked list, one must first make the value into a new LLnode. Then, it is important to change the current back so it is pointing to this new node and then set this new node to back. I made the mistake of thinking that we first change the new back to he new node and then change the old back to point to this node. If it was done this way, we would have lost the reference to the old back. Then after all of this hard work, we have to add one to the size of the linked list.
Drawing pictures for these linked lists helped me very much. I was able to visualize exactly where things needed to go and how they should be coded.
Sunday, 8 March 2015
Binary Search Trees and Transversals
Binary search trees (BST) are just like normal trees but with a few distinctions. BSTs have an arity of 2. This means that a node can only have 2 children, a left child and a right child. The other distinction is that each left subtree is smaller than the root and the right subtree is bigger than the root. This makes searching for elements a lot more efficient because you don't have to transverse the whole tree. You can look for the certain elements based on the fact that the left child is smaller than the root and the the right child is bigger. There is a pattern in the height for these trees. To find the height, one can use log2n where n is the maximum number of nodes for each height. For example. if I had 15 nodes, then the height would be log215 and the answer is 4. Another important fact about binary search trees is that the data has to be comparable. This means that they have to be of the same type because you cannot compare an int to a str (Unless the str is an int in the str format, for which you can convert the str to an int). To help myself learn about these trees, I drew many trees and populated them with different integers to see how the trees would look
The next topic we learned about was transversals. There are different ways to traverse a tree: inorder, preorder and postorder. For example, inorder transverses a tree in the order: left, itself, right. So if we had a regular tree like this:
If we wanted to transverse this tree inorder, we'd start at the root but look at the left child, then this is a new recursive call, so we look at the left child of that child. So in this case, we return 9 because 9 has no left or right children and it is the last node(leaf) of the structure. Then we return to 5 and that is returned. Then we visit 7 and go to its left child. This goes on and on until the whole tree has been transversed. For this specific tree, we'd get:
9, 5, 1, 7, 2, 12, 8, 4, 3, 11
What I had the most trouble with was the fact that each time a new node is visited, it is a new recursive call. So if we start at 8, we check 5, it is a new recursive call so we check left again. This happens over and over until we reach a leaf or in the case of 4, we visit itself before we visit right. I had to draw many trees in order to figure out how to transverse a tree but now that I know, I think transversal is very fun.
The next topic we learned about was transversals. There are different ways to traverse a tree: inorder, preorder and postorder. For example, inorder transverses a tree in the order: left, itself, right. So if we had a regular tree like this:
If we wanted to transverse this tree inorder, we'd start at the root but look at the left child, then this is a new recursive call, so we look at the left child of that child. So in this case, we return 9 because 9 has no left or right children and it is the last node(leaf) of the structure. Then we return to 5 and that is returned. Then we visit 7 and go to its left child. This goes on and on until the whole tree has been transversed. For this specific tree, we'd get:
9, 5, 1, 7, 2, 12, 8, 4, 3, 11
What I had the most trouble with was the fact that each time a new node is visited, it is a new recursive call. So if we start at 8, we check 5, it is a new recursive call so we check left again. This happens over and over until we reach a leaf or in the case of 4, we visit itself before we visit right. I had to draw many trees in order to figure out how to transverse a tree but now that I know, I think transversal is very fun.
Sunday, 1 March 2015
Abstract Data Types (ADT)
In this SLOG, I'll be talking about two structures. Trees and Stacks.
A tree (the data structure) looks like an upside down tree (the biological one). It starts off with the root and then it branches off. The last nodes that don't contain any other nodes are called leaves. There is only one way (path) to get to a specific node and paths cannot go in a circle. Also, two different nodes cannot have a path to the same node. This means that a node's children are exclusively its own children. These structures are levels of organization like XML and html. Recursive functions are also important in the case of trees because there are so many levels, it takes recursion to go through the organization. A tree can have lots of children but there is a catch. All trees have arity. This means the maximum number of children a node can have. This is important because if a tree doesn't have arity, the root would have all the children and it would just be a tree with a height of 2.
Stacks on the other hand are kind of like lists except you can only take off elements one at a time. If you imagine a stack of books, you know what the book at the top is but not the books underneath it. You can put a new book on top or even take the top one off but you can't put a book in the middle of the stack or take one from the middle because then the stack falls apart. The ADT Stack works in the same way. You can pop off the top element, you can push an element on to the top of the stack but you cannot take anything or put anything in the middle of the stack. The only way to see what is in the stack would be to keep popping off elements until the stack is empty. Stacks also have the method is_empty which returns a boolean to answer if the stack is empty or not. This helps when you pop off because while the stack is not empty, you keep popping elements. This is to make sure there is no error or infinity loop. You need to make sure that no more elements are being popped when the stack is empty.
Both of these structures are very helpful. We saw a similar structure to the stack in lab 4. We learned about enqueue and dequeue. They work in a similar way except we pop off the beginning of the list and push to the end. Like how any fast food order would take place. People who were there first would be served first and new people will be lined up in the back. This is different from stacks as people who were pushed lasted would be poped first.
I didn't have too much trouble with these ADTs. The lab really helped me understand them. They are valuable ways to store data. Which data type one picks really depends on how they want their data to be accessed.
A tree (the data structure) looks like an upside down tree (the biological one). It starts off with the root and then it branches off. The last nodes that don't contain any other nodes are called leaves. There is only one way (path) to get to a specific node and paths cannot go in a circle. Also, two different nodes cannot have a path to the same node. This means that a node's children are exclusively its own children. These structures are levels of organization like XML and html. Recursive functions are also important in the case of trees because there are so many levels, it takes recursion to go through the organization. A tree can have lots of children but there is a catch. All trees have arity. This means the maximum number of children a node can have. This is important because if a tree doesn't have arity, the root would have all the children and it would just be a tree with a height of 2.
Stacks on the other hand are kind of like lists except you can only take off elements one at a time. If you imagine a stack of books, you know what the book at the top is but not the books underneath it. You can put a new book on top or even take the top one off but you can't put a book in the middle of the stack or take one from the middle because then the stack falls apart. The ADT Stack works in the same way. You can pop off the top element, you can push an element on to the top of the stack but you cannot take anything or put anything in the middle of the stack. The only way to see what is in the stack would be to keep popping off elements until the stack is empty. Stacks also have the method is_empty which returns a boolean to answer if the stack is empty or not. This helps when you pop off because while the stack is not empty, you keep popping elements. This is to make sure there is no error or infinity loop. You need to make sure that no more elements are being popped when the stack is empty.
Both of these structures are very helpful. We saw a similar structure to the stack in lab 4. We learned about enqueue and dequeue. They work in a similar way except we pop off the beginning of the list and push to the end. Like how any fast food order would take place. People who were there first would be served first and new people will be lined up in the back. This is different from stacks as people who were pushed lasted would be poped first.
I didn't have too much trouble with these ADTs. The lab really helped me understand them. They are valuable ways to store data. Which data type one picks really depends on how they want their data to be accessed.
Sunday, 15 February 2015
All about object oriented programming
The first few things we learned about object oriented programming( OOP) were the basics. We were taught that object oriented programming was about creating something (an object) that is created by a class. If we were to create the object elevator, we'd need to have methods that take the elevator up and one that takes the elevator down. We could also have a method to call for help if there was an emergency. These methods help create this elevator and make the elevator an actual, functioning elevator. We also had to create an __init__ method for classes and this method helps to start up anything that we need prior to creating this object. For example, in the __init__ method for class elevator, we could create a list that would contain how many floors there are in the building. Then, the method for moving up can use this list to figure out if we even have to floor and if it does exist, take the person to that floor. The str and repr methods are pretty similar except the str method is a "prettier" version of the repr method. It needs to be as such because this is what is printed for the user to see and the repr is for the programmer. They are both representations of the class.
The labs themselves are really helpful because I get to play around with the topics we were introduced to. I always try out the labs before the actual lab starts. I haven't had any issues thus far because the topics are pretty self explanatory and if I do have an issue, just playing around in the labs helps answer my question.
I really like learning by myself because I think I get the most learning experience when I learn from my mistakes so while learning about classes, I would keep making new classes and running them to see what values and inputs I get. In the end, it helped me figure out what I wasn't understanding or missing so I could fix it.
The labs themselves are really helpful because I get to play around with the topics we were introduced to. I always try out the labs before the actual lab starts. I haven't had any issues thus far because the topics are pretty self explanatory and if I do have an issue, just playing around in the labs helps answer my question.
I really like learning by myself because I think I get the most learning experience when I learn from my mistakes so while learning about classes, I would keep making new classes and running them to see what values and inputs I get. In the end, it helped me figure out what I wasn't understanding or missing so I could fix it.
Saturday, 7 February 2015
Recursion
Recursion to me was fun. I had heard about recursion before but I had never been formally taught it nor had I seen an example. Personally, I think recursion was the most important and interesting topic we learned about. I had no idea that we could use a function in its own body. It's important when we have nested lists if we wish to do something with the elements of the list. For example, if we want to add up the elements of a nested list, we'd have to use recursion. It is important to have a base case in any recursive function so it can end somewhere. For example, if we wanted to create a function that finds the sum for a nested list, we can check if something is a list and if it is, then go through the list recursively but if it isn't, then just leave it. Then we can add up and return all the numbers using sum.
I think it's a really useful tool to have especially when there is no guarantee of what the parameter could be. For example, if we were required to find the max number from a list and we could be presented with a nested list, we would need to get the max of each list in that list. This is where recursion helps. It can save a lot of effort in complex cases where a step has to be repeated again and again to get the desired solution
The only instance where I had to work with recursion was in the labs. It was my first time implementing recursion. My favourite lab was the one for week 5. We had to work with stacks. We had to create a function that could pick apart a list and add each element to a stack. It seems easy if we were given a list with a depth of 0 but once we are given a list that had more lists inside, recursion became useful. Though recursion is useful, it is important to have a way to end the recursive loop or else it will keep on looping. In other words, it is important to have a base case.
When it came to recursion, it got a little tricky trying to understand it completely because you have to be aware of how many times the recursive call is made. It can get messy. To learn recursion better, looked at different function and ran recursive calls manually to try and figure out the outcome. Then I ran the function on python to check my answer.
The midterm this week also had recursion in it and it wasn't too difficult. It's like a puzzle, you have to go through everything in steps to figure out one by one to get the correct output.
I think it's a really useful tool to have especially when there is no guarantee of what the parameter could be. For example, if we were required to find the max number from a list and we could be presented with a nested list, we would need to get the max of each list in that list. This is where recursion helps. It can save a lot of effort in complex cases where a step has to be repeated again and again to get the desired solution
The only instance where I had to work with recursion was in the labs. It was my first time implementing recursion. My favourite lab was the one for week 5. We had to work with stacks. We had to create a function that could pick apart a list and add each element to a stack. It seems easy if we were given a list with a depth of 0 but once we are given a list that had more lists inside, recursion became useful. Though recursion is useful, it is important to have a way to end the recursive loop or else it will keep on looping. In other words, it is important to have a base case.
When it came to recursion, it got a little tricky trying to understand it completely because you have to be aware of how many times the recursive call is made. It can get messy. To learn recursion better, looked at different function and ran recursive calls manually to try and figure out the outcome. Then I ran the function on python to check my answer.
The midterm this week also had recursion in it and it wasn't too difficult. It's like a puzzle, you have to go through everything in steps to figure out one by one to get the correct output.
Sunday, 1 February 2015
The past few weeks
The last two weeks were pretty fun for me. I had to touch up on my classes so I watched a few youtube videos about how to code them in python. It was very insightful and I found myself watching videos about object oriented programming. Watching the videos really helped me understand classes. I was having trouble understanding what exactly initialization was supposed to be for until we made classes in the labs and I realized it was used to construct anything that we needed before any method is called. For example, if we wanted to create a game where we have a character with health, we'd want to initialize his health first (i.e.self.health = 100%) before we use methods to take away health. Classes are an easy way to be organized. You can keep methods that all related to a certain thing in a class so that you can access it.
The assignment was fun to code. It was a little tricky finding a way to code it so it wasn't specific to the generic classes but I had a really awesome partner and we checked on piazza when we needed to get a better understanding of what the assignment really required us to do. I have never had a partner in any CS class so it was fun getting to collaborate with another brain. We had to discuss all parts of the assignment when normally, I'd just implement whatever I wanted to.
I think the first few weeks were really fun. I was especially impressed with list comprehension because an entire for loop can be replaced with just one line to get the same result.I also had never heard of the module turtle before so being able to learn that it can draw was really amazing.
My professor is Danny and I think he's a really good teacher. He explains concepts very clearly and is very kind. I like the fact that he tries to learn and remember everyone's names. I'm really looking forward to the rest of this class so I can learn more about python and the things I can do and code with it.
The assignment was fun to code. It was a little tricky finding a way to code it so it wasn't specific to the generic classes but I had a really awesome partner and we checked on piazza when we needed to get a better understanding of what the assignment really required us to do. I have never had a partner in any CS class so it was fun getting to collaborate with another brain. We had to discuss all parts of the assignment when normally, I'd just implement whatever I wanted to.
I think the first few weeks were really fun. I was especially impressed with list comprehension because an entire for loop can be replaced with just one line to get the same result.I also had never heard of the module turtle before so being able to learn that it can draw was really amazing.
My professor is Danny and I think he's a really good teacher. He explains concepts very clearly and is very kind. I like the fact that he tries to learn and remember everyone's names. I'm really looking forward to the rest of this class so I can learn more about python and the things I can do and code with it.
Wednesday, 21 January 2015
Why Geeks Should Write
Writing is a form of expression, and expression is important in the logical field of computer science. Programming is such an extremely precise form of communication that it can sometimes be difficult to understand what the creator really was trying to achieve. In this case, being able to write articulately is extremely important. One can be the greatest coder of all time but without the proper communication skills, it would be difficult for them to fully explain themselves. This would make it harder to work with them in a team settings as well as read and understand their code.
It is helpful writing about experiences and problems as well as solutions to those problems. This proves to serve as a reminder if such a problem were to arise at a later date. It is a bonus if the writing is published for a larger audience because if someone else is having the same problem, they too will be relieved of their issue. Apart from that, if a problem were to arise that one could not fix, someone else may have a possible solution. While writing about the problem in a less logical sense, it is possible that one can come up with a solution because they were thinking about it in a less logical way.
In a more general case, being able to write is necessary for everyday life. It helps in many situations to be able to eloquently argue with or persuade someone. It is also important to be able to properly explain oneself if need be in any argument.
Since writing is a form of expression, writing may help one to get any personal problems or feelings out. It can also serve as a way to store memories which can then be referred to in some point in the future when one is old and grey haired.
Writing in any form will always pose as a benefit and thus, I think it is important for all geeks to write
The course so far did help me build on what I had learned in CSC108. In all honesty, it was a little hard to fully get a grasp on what classes were for. I was in the online class for the videos weren't as much help as I had hoped. Being in CSC148, and being in an actual class for it (instead of an online course) helped me understand better what I was supposed to be doing because I could has questions and get more insight into the specific class we were working on, where as we had fixed videos with little room to ask questions in my online class.
It is helpful writing about experiences and problems as well as solutions to those problems. This proves to serve as a reminder if such a problem were to arise at a later date. It is a bonus if the writing is published for a larger audience because if someone else is having the same problem, they too will be relieved of their issue. Apart from that, if a problem were to arise that one could not fix, someone else may have a possible solution. While writing about the problem in a less logical sense, it is possible that one can come up with a solution because they were thinking about it in a less logical way.
In a more general case, being able to write is necessary for everyday life. It helps in many situations to be able to eloquently argue with or persuade someone. It is also important to be able to properly explain oneself if need be in any argument.
Since writing is a form of expression, writing may help one to get any personal problems or feelings out. It can also serve as a way to store memories which can then be referred to in some point in the future when one is old and grey haired.
Writing in any form will always pose as a benefit and thus, I think it is important for all geeks to write
The course so far did help me build on what I had learned in CSC108. In all honesty, it was a little hard to fully get a grasp on what classes were for. I was in the online class for the videos weren't as much help as I had hoped. Being in CSC148, and being in an actual class for it (instead of an online course) helped me understand better what I was supposed to be doing because I could has questions and get more insight into the specific class we were working on, where as we had fixed videos with little room to ask questions in my online class.
Subscribe to:
Posts (Atom)
