Binary Search Tree (Module 8.2) PART II Flashcards
For the initial call for global range constraints, we should start with (______, ________) at the root of the tree.
(INT_MIN, INT_MAX)
For the initial call, why do we start with (INT_MIN, INT_MAX)?
so the root can have any valid integer value
For the left subtree in global constraints, when moving to the left child of a node with value v, the allowable range is updated to ______, ___).
(INT_MIN, v)
For global contraints, why is (INT_MIN, v) used to update the range in the left subtree?
so all values in the left subtree are less than v
For the left subtree in global constraints, when moving to the right child of a node with value v, the allowable range is updated to
(__, _______).
(v, INT_MAX)
For global contraints, why is (v, INT_MAX) used to update the range in the right subtree?
so all values in the right subtree are larger than v
Is Global binary search tree (BST) necessary for a binary tree to work as a valid binary search tree?
Yes!
What are the 3 advantages of enforcing the Global BST property?
1) correctness
2) efficiency
3) avoid false positives
For inserting in a BST, what happens to the new node if the tree is empty?
it becomes the root of the tree
In a binary search tree (BST), insertions are always done at what level?
leaf node level
Is it possible to insert a node at a non-leaf position without violating the global and local constraints of BST?
no! (it’s no longer a valid BST)
What is the best case time complexity for a binary search tree insertion?
O(log n)
What is the worst case time complexity for binary search tree insertion?
O(n)
What is the space complexity for binary search tree insertion?
O(h)