Binary Search Tree (Module 8.2) PART I Flashcards

1
Q

If using a poor hash function, hash tables could run in _________ time complexity.

A

O(n)

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

When developing a data structure, make sure that it always guarantees _________ worst-case complexity for lookup, insert, and find_min.

A

O(1)

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

When searching for a number x using binary search, always start by looking at the ________.

A

midpoint

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

In a tree, what should blank left/right fields point to?

A

null

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

Each sequence of left/right pointers works like what kind of list?

A

null-terminated list

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

What is the best case time complexity for lookup, insert, and find_min?

A

O(log n)

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

What is a tree with ordered nodes?

A

Binary Search Tree

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

In an ordered tree, smaller values are on the ______ and larger values are on the_____.

A

left, right

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

In an empty tree, the key is __________.

A

not found

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

In a non-empty tree, if the root contains the key, it’s ________.

A

found

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

In a non-empty tree, if the key is smaller than the root’s, go ____.

A

left

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

In a non-empty tree, if the key is bigger than the root’s, go _____.

A

right

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

True or false: ‘<, ==, and >’ only work for integers.

A

true

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

Should a tree store entries for any type?

A

yes!

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

What does a binary search tree need to declare a method to compare two keys?

A

client interface

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

When checking nodes ordering, the data in every node must be ________ than its right child and ________ than its left child.

A

smaller, larger

17
Q

To make sure a tree is ordered, what do we need?

A

global constraint

18
Q

What is the global contraint?

A

T(L) < y < T(R)

19
Q

What is the local contraint?

20
Q

What is the difference between global constraint and local constraint?

A

global checks the whole subtrees while local only checks the child of each node