Map ADT Flashcards
What are the main methods of the Map ADT?
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
What is a map?
A searchable collection of key-value entries that support searching, insertion and deletion
What is the definition of a binary search tree?
a binary tree where each right child is strictly larger than the parent, and each left child is strictly smaller.
how do we remove an element from a binary tree? if the element we are removing has one child
promote the child upwards to replace the element
how do we remove an element from a binary tree? if the element we are removing has two children
- locate the predecessor
- move this up to replace the element
- remove the predecessor
What is the predecessor in a binary tree?
The largest child of the left hand child of an element
What is the predecessor in a binary tree?
The largest child of the left hand child of an element
What is the performance of a binary search tree’s size and isEmpty method?
Worst case theta 1
What is the performance of a binary search tree’s get, put and remove methods?
Worst case theta height