CS 1332 Final Exam Big-O Review

0.0(0)
studied byStudied by 36 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/107

flashcard set

Earn XP

Description and Tags

Assume worst case unless specified

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

108 Terms

1
New cards

Adding to the back of an ArrayList

O(1)*

2
New cards

Adding to any index ArrayList

O(n)

3
New cards

Removing from an ArrayList

O(n)

4
New cards

Removing from back of an ArrayList

O(1)

5
New cards

Accessing from an ArrayList

O(1)

6
New cards

Accessing from a SLL no tail

O(n)

7
New cards

Adding to the front of a SLL

O(1)

8
New cards

Adding to the front of a DLL

O(1)

9
New cards

Adding to the back of a SLL w/ tail

O(1)

10
New cards

Adding to the back of a DLL

O(1)

11
New cards

Removing from the back of a SLL

O(n)

12
New cards

Removing from the back of a DLL

O(1)

13
New cards

Removing from the front of a SLL

O(1)

14
New cards

Removing from the front of a DLL

O(1)

15
New cards

Pushing onto a SLL-backed stack

O(1)

16
New cards

Popping off a SLL-backed stack

O(1)

17
New cards

Pushing onto an Array-backed stack

O(1)*

18
New cards

Popping off an Array-backed stack

O(1)

19
New cards

Enqueuing into a SLL-backed queue

O(1)

20
New cards

Dequeuing from a SLL-backed queue

O(1)

21
New cards

Enqueuing into an Array-backed queue

O(1)*

22
New cards

Dequeuing from an Array-backed queue

O(1)

23
New cards

addFirst() in a DLL-backed Deque

O(1)

24
New cards

addLast() in a DLl-backed Deque

O(1)

25
New cards

removeFirst() in a DLL-backed Deque

O(1)

26
New cards

removeLast() in a DLL-backed Deque

O(1)

27
New cards

addLast() in an Array-backed Deque

O(1*

28
New cards

addFirst() in an Array-backed Deque

O(1)*

29
New cards

removeFirst() in an Array-backed Deque

O(1)

30
New cards

removeLast() in an Array-backed Deque

O(1)

31
New cards

Performing any traversal on a tree

O(n)

32
New cards

Worst case of adding to a BST

O(n)

33
New cards

Average case of adding to a BST

O(log n)

34
New cards

Worst case of removing from a BST

O(n)

35
New cards

Average case of removing from a BST

O(log n)

36
New cards

Best case of searching BST

O(1) - when data is in root

37
New cards

Average case of searching BST

O(log n)

38
New cards

Worst case of searching BST

O(n)

39
New cards

Adding to a heap

O(log n)*

40
New cards

Removing from a heap

O(log n)

41
New cards

BuildHeap()

O(n)

42
New cards

Building a heap by calling add() on each element

O(n log n)

43
New cards

Adding to a hashmap Ex.Chaining

O(n)

44
New cards

Removing from a hashmap

O(n)

45
New cards

Searching in a hashmap

O(n)

46
New cards

Adding to an AVL

O(log n)

47
New cards

Removing from an AVL

O(log n)

48
New cards

Searching in an AVL

O(log n)

49
New cards

Getting the height of AVL

O(1)

50
New cards

Traversing an AVL

O(n)

51
New cards

Best case of searching, adding, or removing from a SkipList

O(1)

52
New cards

Average case of searching, adding, or removing from a SkipList

O(log n)

53
New cards

Worst case of searching, adding, or removing from a SkipList

O(n) - degenerates to just a LinkedList

54
New cards

Worst case of space complexity for a SkipList

O(n log n)

55
New cards

Removing from 2-4 tree

O(log n)

56
New cards

Adding to a 2-4 tree

O(log n)

57
New cards

Searching in a 2-4 tree

O(log n)

58
New cards

Worst case of Bubble Sort

O(n^2) - reverse sorted array

59
New cards

Best case of Bubble Sort

O(n)

60
New cards

Worst case of Insertion Sort

O(n^2) - reverse sorted array

61
New cards

Best case of Insertion Sort

O(n)

62
New cards

Selection Sort

O(n^2)

63
New cards

Worst case of Cocktail Shaker Sort

O(n^2) - reverse sorted array

64
New cards

Best case of Cocktail Shaker Sort

O(n)

65
New cards

Merge Sort

O(n log n)

66
New cards

Worst case of In-Place Quicksort

O(n^2) - pivot is always min or max value of subarray

67
New cards

Best case of In-Place Quicksort

O(n log n)

68
New cards

LSD Radix Sort

O(kn)

69
New cards

Worst case of QuickSelect

O(n^2)

70
New cards

Best case of QuickSelect

O(n)

71
New cards

Best case of Brute Force if no occurrences of pattern are in text

O(n)

72
New cards

Worst case of Brute Force if no occurrences of pattern are in text

O(nm)

73
New cards

Best case of Brute Force to find single occurrence

O(m)

74
New cards

Worst case of Brute Force to find single occurrence

O(mn)

75
New cards

Best case of Brute Force to find all occurrences

O(n)

76
New cards

Worst case of Brute Force to find all occurrences

O(mn)

77
New cards

Creating the Last Occurrence Table

O(m)

78
New cards

Best case of Boyer Moore if no occurrences of pattern are in text

O(m + n/m)

79
New cards

Worst case of Boyer Moore if no occurrences of pattern are in text

O(mn)

80
New cards

Best case of Boyer Moore to find single occurrence

O(m)

81
New cards

Worst case of Boyer Moore to find single occurrence

O(mn)

82
New cards

Best case of Boyer Moore to find all occurrences

O(m + n/m)

83
New cards

Worst case of Boyer Moore to find all occurrences

O(mn)

84
New cards

Using KMP to find all occurrences

O(m + n)

85
New cards

Using KMP if no occurrences of the pattern are in the text

O(m + n)

86
New cards

Best case of KMP to find single occurrence

O(m)

87
New cards

Worst case of KMP to find single occurrence

O(m+n)

88
New cards

Creating the Failure Table

O(m)

89
New cards

Best case of Rabin Karp if no occurrences of pattern are in text

O(m + n)

90
New cards

Worst case of Rabin Karp if no occurrences of pattern are in text

O(mn)

91
New cards

Best case of Rabin Karp to find single occurrence

O(m)

92
New cards

Worst case of Rabin Karp to find single occurrence

O(mn+m)

93
New cards

Worst case of Rabin Karp to find all occurrences

O(mn+m)

94
New cards

Best case of Rabin Karp to find all occurrences

O(m + n)

95
New cards

Space complexity of Adjacency Matrix

O(|V|^2)

96
New cards

Space complexity of Adjacency List

O(|V|²)

97
New cards

Space complexity of Edge List

O(|E|)

98
New cards

Big O of Depth First Search

O(|V| + |E|)

99
New cards

Big O of Breadth First Search

O(|V| + |E|)

100
New cards

Big O of Dijkstra's

O(|E| log |E|)