>>> x = LinkedList(2, LinkedList(3, LinkedList(4)))
>>> str(x)
“2 -> 3 -> 4 -> None”
>>> x
2 -> 3 -> 4 -> None
In that example above, I performed a few lines on the LLNode function that was provided in lecture. I understood the point of objects pointing to another object and so forth.
The fundamental principle of BST's is that all the data in the left subtree is less than the root, and all the data in the right subtree is larger than the root. The implementation that was used was the wrapper approach (similar to linked list) in that there was a class for a BSTNode and a class for the whole BST. Throughout the lectures for the week we worked through coding common methods such as insert and delete, using recursion. Danny also showed us the significance of helper functions, which made the coding a lot easier too see.
>>> x = BST([5, 3, 6, 7])
>>> print(x)
7
6
5
3
It was saying that whatever value is at the start of the BST will be the root, and it iterates over the values afterwards. So if I say [5, 3, 6, 7], 5 will be the node, 3 will be the left branch and 6 will be the right branch, because 3 is less than 5 and 6 is greater than 5. 7 will be placed on the right of 6. So in all this will be how it will look like on the python shell:
Following student was able to write interesting slog entry every week. Good job!
ReplyDelete