Map ADT Flashcards

1
Q

What are the main methods of the Map ADT?

A

get(element) - if map has an entry element, return its associated value
put(element, value) - if map does not have an entry element, add element, value into map
remove(element) - if map has element, remove it and its value

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

What is a map?

A

A searchable collection of key-value entries that support searching, insertion and deletion

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

What is the definition of a binary search tree?

A

a binary tree where each right child is strictly larger than the parent, and each left child is strictly smaller.

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

how do we remove an element from a binary tree? if the element we are removing has one child

A

promote the child upwards to replace the element

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

how do we remove an element from a binary tree? if the element we are removing has two children

A
  • locate the predecessor
  • move this up to replace the element
  • remove the predecessor
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the predecessor in a binary tree?

A

The largest child of the left hand child of an element

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

What is the predecessor in a binary tree?

A

The largest child of the left hand child of an element

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

What is the performance of a binary search tree’s size and isEmpty method?

A

Worst case theta 1

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

What is the performance of a binary search tree’s get, put and remove methods?

A

Worst case theta height

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