Block 2: Trees and Advanced Data Structures Flashcards
what is an ADT?
Abstract Data Type
what is a data structure?
a concrete way of organising data in memory
what are 4 stack operations?
push(x), pop(), top(), isEmpty()
what is the order of a stack?
LIFO
what are 2 implementations of a stack?
linked list and dynamic array
what are 2 operations of a linked list?
push and pop
what is the theta value of a linked list?
Θ(1)
what is the average theta value of a dynamic list?
Θ(1)
what is the worst case of an operation on a dynamic list?
Θ(n)
What are the 4 queue operations?
Enqueue(x), dequeue(), Front(), isEmpty() or size()
What order does a queue work in?
FIFO
What are 2 applications of queues?
Buffering, Breadth-first Search
what operations do we expect small ADTs to have?
add(x), min(), max(), contains(x), delete(x)
what ADT did we cover in last year’s CS1860?
sets
What is a map ADT also known as?
dictionary / associative array
what is an unordered implementation of an ADT?
Hashtable
What is an ordered implementation of an ADT?
Balanced Binary Search Tree
What is the main concept of a binary tree?
the left subtree contains smaller values, and larger values are on the right
what operations do we look at for BSTs?
insert(x), lookup(x), min(), max(), successor(x), delete(x)
what time does any operation on a BST take maximum?
O(h) where h is the height of the tree
what is the best height for a tree with n elements?
O(log n)
what is the worst height for a tree with n elements?
n-1
how do you remove t from a BST if t is a leaf?
just remove it