Corina Flashcards

1
Q

What is Big-Theta Notation

A

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

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

What is time complexity?

A

The computational complexity that describes the amount of computer time it takes to run an algorithm

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

What is asymptotic behaviour of a running time?

A

What happens when n becomes very large

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

What are the advantages of Big-Theta Notation?

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the disadvantages of Big-Theta Notation?

A
  • Can not compare algorithms whose running times have the same rate of growth
  • Small inputs Big-Theta can be misleading
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is Big-O notation?

A
  • Gives the upper bound for the rate of growth
  • it is true for either worst/average/best case
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is Big-Omega Notation?

A
  • Gives the lower bound for the rate of growth
  • It is true for either worst/average/best case
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the Big-O notation equation?

A

f(n) is O(g(n)) if there exist constants d > 0 and N ∈ N s.t.
f(n) ≤ dg(n) for n ≥ N

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

What is the Big-Omega notation equation?

A

f(n) is Ω(g(n)) if there exist constants c > 0 and N ∈ N s.t.
f(n) ≥ cg(n) for n ≥ N

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

What is the access time of arrays?

A

Θ(1)

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

How are arrays stored?

A

They use a contiguous chunk of memory

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

What is the time complexity of a stack?

A

Θ(1)

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

What is the memory requirement of a stack?

A

Θ(n)

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

What is a doubly linked list?

A

Allows for Θ(1) add and remove at both ends

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

What is a dummy node used for?

A

To make implementation slicker

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

How are skip lists more beneficial than linked lists?

A

Skip lists are hierarchies of linked lists which support binary search

17
Q

What is the search time complexity of skip lists?

A

Θ(log(n))

18
Q

What advantage do skip lists have over binary trees?

A

They allow efficient concurrent access

19
Q

What is a tree?

A

An acyclic undirected graph

20
Q

What is a binary tree?

A

A tree where each node can have zero, one or two children

21
Q

What is the total number of possible nodes?

22
Q

How do you search a binary tree?

A
  • Start at the root
  • Compare the element
  • If less than element go left
  • If greater than element go right
  • If equal to element found
23
Q

How do we iterate through trees?

A
  • 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
24
Q

How do we remove an element with two children from a tree?

A
  • Replace that element by its successor
  • And then remove the successor using the above procedure
25
Q

How can we change the shape of trees to avoid unbalanced trees?

26
Q

What are the 4 types of rotation?

A
  • Left Rotation
  • Right rotation
  • Left-right double rotation
  • Right-left double rotation
27
Q

What is an AVL tree?

A

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

28
Q

What is the worst case of rotations for an AVL tree?

A

Θ(log(n))

29
Q

What is the height of an AVL tree?

A

Θ(log(n))

30
Q

What is the worst case for insertion, deletion and search in an AVL tree?

A

Θ(log(n))