Binary Search Tree Flashcards
What is a Binary Search Tree?
a tree data structure in which nodes are arranged according to the BST property. The left node is less than the node, and the right node is greater than the node. If the left child node or right child node is non-existent, then it will contain null value
How do you insert data into a Binary Search Tree?
We start from the root node and compare the new value to be inserted with the current node’s value. We continue this comparison until we find a null position.
NOTE: We want to avoid linear binary search trees as it voids the value of using a Binary Search Tree – which is speed in search operation since we can immediately ignore have of the tree. A linear structure makes the time complexity O(n), whereas non-linear we can achieve a time complexity of O(logn)
How do you search a Binary Search Tree?
similar to the process for inserting data