Sunday, 29 March 2015

My impression of week#9 - BST mutation (week #10)

The topic in week #7 is the binary search tree mutation - deleting and inserting nodes in the binary search tree.

We just had one hour lecture due to the term test #2 and we had to do the lab exercise on our own due to the strike, I'm not very confident about what we learned this week. Actually I have many doubles.

In the lab exercise #8, there were not many things to do. We just need to do some experiment on functions '_insert' and '_delete'.

I'm ok with the function '_insert'. It inserts nodes into the binary search tree in order.
The other functions like '_height', 'contains' and '_find_max' are also easy to understand (Basically very similar to what we did in lab#6 with regard to the BTNode).

What confuses me the most is the function '_delete'. I tried it many times on the nodes at the root, at leaves and in the middle. It worked very well. But I read the code many times and tried to trace it on paper but I still don't understand how it works. I'll go to the office hours for help the next week.



Another difficulty is that I don't understand why we need the class BST. I think we just need to write a class called 'BSTNode' with all the method and functions for BTNode and for BST. I'll ask this question in the office hours, too.

One thing I should have recorded in week#7's SLOG but forgot is the tree traversal. Our prof didn't talk about it very much so I didn't pay attention to it until we had term test #2 this week and had it covered in the test. Actually this concept is very important because for the most of the time when we're writing the code for a binary tree, we use tree traversal. We mainly practice three kinds of tree traversal: post-order, in-order and pre-order. The following pictures clearly express how they work respectively:



No comments:

Post a Comment