Hi everyone!!
Last week in class we learned about BST Mutation. A binary search tree (BST) is a tree where each node’s value is greater than all values in its left subtree but smaller than all the values in its right subtree. The way we coded for a typical BST in Python was by creating two classes- BTNode and BST. BTNode represented one node in the BST while BST represented the whole Binary Search Tree structure.
Now that you understand what each class was like in the implementation of a BST, we can discuss the methods we coded for that mutated the BST: insert and delete.
Last week in class we learned about BST Mutation. A binary search tree (BST) is a tree where each node’s value is greater than all values in its left subtree but smaller than all the values in its right subtree. The way we coded for a typical BST in Python was by creating two classes- BTNode and BST. BTNode represented one node in the BST while BST represented the whole Binary Search Tree structure.
Now that you understand what each class was like in the implementation of a BST, we can discuss the methods we coded for that mutated the BST: insert and delete.
To aid us in
thinking effectively, we drew pictures with various cases that may be encountered
and designed our code in a way that the code would work properly for each case.
The coding was pretty complicated because there are many cases that need to be
taken into consideration when developing a proper, efficient code but the whole
concept of a BST is extremely useful and efficient. Finding an item in a BST is
much easier than finding it in a traditional tree as it is sorted in a way and essentially
cuts the search time in half.
Anyway, I’m certain
that the concept of trees is crucial in the world of Computer Science and I
will have to work on more methods that mutate trees to become more confident in
developing code that performs mutations to Abstract Data Types.
Till next week, thanks!!
=)
No comments:
Post a Comment