Binary Search Tree (Module 8.2) PART II Flashcards

1
Q

For the initial call for global range constraints, we should start with (______, ________) at the root of the tree.

A

(INT_MIN, INT_MAX)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

For the initial call, why do we start with (INT_MIN, INT_MAX)?

A

so the root can have any valid integer value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

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 ______, ___).

A

(INT_MIN, v)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

For global contraints, why is (INT_MIN, v) used to update the range in the left subtree?

A

so all values in the left subtree are less than v

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

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
(__, _______).

A

(v, INT_MAX)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

For global contraints, why is (v, INT_MAX) used to update the range in the right subtree?

A

so all values in the right subtree are larger than v

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Is Global binary search tree (BST) necessary for a binary tree to work as a valid binary search tree?

A

Yes!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are the 3 advantages of enforcing the Global BST property?

A

1) correctness
2) efficiency
3) avoid false positives

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

For inserting in a BST, what happens to the new node if the tree is empty?

A

it becomes the root of the tree

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

In a binary search tree (BST), insertions are always done at what level?

A

leaf node level

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Is it possible to insert a node at a non-leaf position without violating the global and local constraints of BST?

A

no! (it’s no longer a valid BST)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the best case time complexity for a binary search tree insertion?

A

O(log n)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the worst case time complexity for binary search tree insertion?

A

O(n)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the space complexity for binary search tree insertion?

A

O(h)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly