Again I came here after not understanding the concept in another video and yes, Tim never disappoints me.. His video was clear and it's even easy for beginners like me to grasp the code.. Thanks million..!
Dude, this video is pure gold. I'm trying to really get into algo and data structure and this is clearing up so many things for me ! It deserves way more views !
The insertion time to the tree is log(n) only if the tree is balanced, If you insert a set of numbers are in increasing (or decreasing) order, you end up with a binary tree that has a height of (n)
If you are coming to the idea of a BST for the first time there is something you need to know. The idea is to take a piece of information like a surname, and convert it to a unique number. You do this with a 'hash function'. That number is the 'key' associated wtih that piece of data. The data is then inserted into a BST in the way described by Tim. Now if you want to search for a name, you obtain the'key' by hashing the name you want to search for. Using that 'key' you can swiftly search the BST and get the information associated with the key.
In the add() function, aren't we supposed to declare current = self.ptr_to_root? Because, otherwise how can we use it the way we have? It is not defined at all. Please explain me If I am wrong! Wanting to learn.
I think code for traversing is wrong... You are not handling the None case, like when we reach the end of the tree, we cannot print any thing like node.value.. please have a look
The implementation of "add" will fall into a linked list if the elements are inserted in perfect order. So the time complexity will degrade to O(n), which is not log(n) anymore.
can you please post some videos on data structure and algorithms using python (BST,heaps,sorting,dijkshtra algorithm,bellman ford algorithm, prims and kruskals algorithm , graph algorithms etc)
how are you getting the value from current if current isn’t connected to the node in any way, current should be an empty variable because you didn’t do assign anything to it
I could not understand the "current" argument passed. You seem to talk more and demonstrate with example very less. I expected a better tutorial from you.
How do we call the function ? BST=BinarySearchTree() BST.add(5) BST.add(8) BST.add(7) BST.add(12) BST.add(1) BST.add(10) BST.add(2) I did this and I am unable to get the required results I am getting an error "ST.add(5) TypeError: BinarySearchTree.add() missing 1 required positional argument: 'value' " Somebody please help me with this