Corina Flashcards
What is Big-Theta Notation
f(n) is Θ(g(n)) if there exist constants c > 0, d > 0 and N ∈ N
such that
cg(n) ≤ f(n) ≤ dg(n) for n ≥ N
What is time complexity?
The computational complexity that describes the amount of computer time it takes to run an algorithm
What is asymptotic behaviour of a running time?
What happens when n becomes very large
What are the advantages of Big-Theta Notation?
- We can compare algorithms by comparing the rates of growth of their running times
- We can estimate algorithm running times on large inputs by measuring running time on a small input
What are the disadvantages of Big-Theta Notation?
- Can not compare algorithms whose running times have the same rate of growth
- Small inputs Big-Theta can be misleading
What is Big-O notation?
- Gives the upper bound for the rate of growth
- it is true for either worst/average/best case
What is Big-Omega Notation?
- Gives the lower bound for the rate of growth
- It is true for either worst/average/best case
What is the Big-O notation equation?
f(n) is O(g(n)) if there exist constants d > 0 and N ∈ N s.t.
f(n) ≤ dg(n) for n ≥ N
What is the Big-Omega notation equation?
f(n) is Ω(g(n)) if there exist constants c > 0 and N ∈ N s.t.
f(n) ≥ cg(n) for n ≥ N
What is the access time of arrays?
Θ(1)
How are arrays stored?
They use a contiguous chunk of memory
What is the time complexity of a stack?
Θ(1)
What is the memory requirement of a stack?
Θ(n)
What is a doubly linked list?
Allows for Θ(1) add and remove at both ends
What is a dummy node used for?
To make implementation slicker
How are skip lists more beneficial than linked lists?
Skip lists are hierarchies of linked lists which support binary search
What is the search time complexity of skip lists?
Θ(log(n))
What advantage do skip lists have over binary trees?
They allow efficient concurrent access
What is a tree?
An acyclic undirected graph
What is a binary tree?
A tree where each node can have zero, one or two children
What is the total number of possible nodes?
2^l
How do you search a binary tree?
- Start at the root
- Compare the element
- If less than element go left
- If greater than element go right
- If equal to element found
How do we iterate through trees?
- We start at the left-most branch
- If right child exists then move right once and then move as far left as possible
- Else go up to the left as far as possible and then move up right
How do we remove an element with two children from a tree?
- Replace that element by its successor
- And then remove the successor using the above procedure
How can we change the shape of trees to avoid unbalanced trees?
Rotations
What are the 4 types of rotation?
- Left Rotation
- Right rotation
- Left-right double rotation
- Right-left double rotation
What is an AVL tree?
A binary search tree in which
1. the heights of the left and right subtree differ by at most 1
2. the left and right subtrees are AVL trees
What is the worst case of rotations for an AVL tree?
Θ(log(n))
What is the height of an AVL tree?
Θ(log(n))
What is the worst case for insertion, deletion and search in an AVL tree?
Θ(log(n))