Big O Flashcards

(39 cards)

1
Q

Insert in ordered array

A

O(n)

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

Removal from ordered array

A

O(n)

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

Linear Search # of comparisons Best Case

A

found as first element

1 comparison

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

Linear Search # of comparisons worst case

A

n comparisons

when element is last element or not in the array

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

Linear Search number of comparisons in average case

A

(3n+1)/4 comparisons

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

Binary Search # of comparisons best case

A

1 comparison

element wanted is in the middle of the array

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

Binary search # of comparisons worst case

A

log(n) + 1 comparisons

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

Binary Search # of comparisons average case

A

closer to worst case then best case

more likely to find the element as the search space gets smaller

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

Selection Sort Barometer Operation

A

n*(n-1)/2

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

Selection Sort # of swaps

A

n-1

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

Insertion sort # of comparisons Worst case

A

n*(n-1)/2

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

Insertion sort # of comparisons best case

A

n comparisons (no moves)

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

Insertion sort # of comparisons average case

A

n*(n-1)/4

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

Quick sort best case run time

A

O(n log n)

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

Quick sort average case run time

A

O( n log n)

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

Quick sort worst case run time

17
Q

Selection sort best case run time

18
Q

Selection sort average case run time

19
Q

Selection sort worst case run time

20
Q

Insertion sort best case run time

21
Q

Insertion sort average case run time

22
Q

Insertion sort worst case run time

23
Q

Mergesort best case run time

24
Q

Merge sort average case run time

25
Merge sort worst case run time
O(nlogn)
26
HeapSort best case run time
O(nlogn)
27
HeapSort average case run time
O(nlogn)
28
HeapSort worst case run time
O(nlogn)
29
Data structure- insertion, delete, look up - run time
O(log n)
30
BST insertion, removal, search cost
O(height)
31
sorting an array with BST run time
O(n * h) | if balanced than O(nlogn)
32
Run time of Priority Queues insert and remove
O(log n)
33
Heap # of swaps for insertion
height swaps
34
Heap number of comparisons for removal
height * 2 compariosns
35
Run time for insertions and removal from a heap
O(log n)
36
Heap removal of a node run time
O(logn)
37
Heap removal of a node run time
O(nlogn)
38
cost to heapify an array
O(n)
39
Time complexity of Radix Sort
O(n*k) | where n values of at most k digits