Big 0 Time Flashcards

1
Q

Linear Time

A

O(n)

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

Constant Time

A

O(1)

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

Quadratic Time

A

O(n^2)

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

What scenario do we care about when measuring time complexity?

A

Worst case scenario/upper bound

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

Logarithmic Time

A

O(logn)

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

Traveling Salesman Time Complexity

A

O(n!)

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

Bubble Sort Time Complexity

A

O(n^2)

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

Insertion Sort Time Complexity

A

O(n^2)

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

Merge Sort Time Complexity

A

O(nlogn)

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

Quicksort Time Complexity

A

O(nlogn)

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

Binary Search Time Complexity

A

O(logn)

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

First Recurring Character in a string Time Complexity

A

O(n^2)

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

Rank the algorithms Rate of Increase for Big O

A

O(logn)>O(n)>O(nlogn)>O(n^2)>O(2^n)>O(n!)

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

When there is a function with multiple calls, the runtime will often be:

A

O(branches^depth)

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

Binary Tree Insert/find

A

O(logn)

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

Hash Table

A

constant time O(1)

17
Q

Linked List

A

O(n)

18
Q

Objects

A

Constant time for lookup/insert/removal, linear time for searching O(n)

19
Q

Arrays

A

Access O(1), Searching O(n), Insertion/Removal depends on beginning or end

20
Q

Binary Heap

A

Insert/Remove O(logn)

21
Q

Graph: Adjacency Matrix vs List Edge Tradeoffs

A

List:

  • Takes up less Space
  • Faster iteration over edges
  • Slower to query edge

Matrix:

  • Takes up more space (in sparse graphs)
  • Longer to iterate over edges
  • Faster to query an edge