With the continuation of the TA strike, tutorials and labs are still cancels, hopefully it will resolve soon. Though technically we still don’t have labs anymore, we are still responsible for the materials covered in the labs. But due to my laziness, I still have got myself to get working on the labs yet. I might use some of the time over the weekend to work through the labs myself. With this being the third week of the TA strike, I start to wonder what will happen to the marks that are acquired to attending the tutorials and labs.
This week in lecture, we went back to BSTs (Binary Search Tree). We explored through the steps required to change a BST, for example, if we were to trying to add an element to the binary search tree what steps are required to complete this method? We know that a binary search tree has a property of having elements whose value is less than its current value on the left of the tree and values which is larger than the current value in the current node on the right of the tree. Knowing this, we are able to write a recursive method that compares the value being added to the value of the current node and to its children nodes until there is no more comparison to be made and add the value to the BST at the right position. The other method of BST we implemented in class was delete, this method allows us to delete a node from the BST. It gets complicated when the node we are deleting is not a leaf, which requires us to replace the deleted node who is not a leaf with the right most leaf of the left subtree or the left most leaf of the right subtree. The algorithm of this method is a bit long, therefore the professor recommends us to write out an implementation comment whenever we encounter problems that requires multiple steps to solve the problem. I thinking that writing an implementation comment is quite useful because I usually don't have the incentive to write the comments before i finish writing the code, and having the algorithm of the code written down before I start implementing it could be helpful in keeping my mind clear on the objective. I will definitely try to develop the habit of writing comments on what I need to implement before I actually implement the code. At the end, I was able to understand the examples that we discussed in lectures and I hope I am able to work through the problems in labs.
No comments:
Post a Comment