Sorting and Patterning Searching Algorithms Time Complexity and more

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

1/93

flashcard set

Earn XP

Description and Tags

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

94 Terms

1
New cards

Bubble Sort Best Case Big O

O(n)

2
New cards

Bubble Sort Average Case Big O

O(n²)

3
New cards

Bubble Sort Worst Case Big O

O(n²)

4
New cards

Bubble Sort: Stable?

Yes.

5
New cards

Bubble Sort Adaptable?

Yes

6
New cards

Bubble Sort: In/out of place?

In

7
New cards

Insertion Sort Best Case Big O

O(n)

8
New cards

Insertion Sort Average Case Big O

O(n²)

9
New cards

Insertion Sort Worst Case Big O

O(n²)

10
New cards

Insertion Sort: Stable?

Yes

11
New cards

Insertion Sort Adaptable?

Yes

12
New cards

Insertion Sort In/out of place?

In

13
New cards

Cocktail Shaker Sort Best Case Big O

O(n)

14
New cards

Cocktail Shaker Sort Average Case Big O

O(n²)

15
New cards

Cocktail Shaker Sort Worst Case Big O

O(n²)

16
New cards

Cocktail Shaker Sort: Stable?

Yes

17
New cards

Cocktail Shaker Sort: Adaptable?

Yes

18
New cards

Cocktail Shaker Sort: In/out of place?

In

19
New cards

Selection Sort Best Case Big O

O(n²)

20
New cards

Selection Sort Average Case Big O

O(n²)

21
New cards

Selection Sort Worst Case Big O

O(n²)

22
New cards

Selection Sort: Stable?

No

23
New cards

Selection Sort: Adaptable?

No

24
New cards

Selection Sort: In/out of place?

In

25
New cards

QuickSort Best Case Big O

O(n log n)

26
New cards

QuickSort Average Case Big O

O(n log n)

27
New cards

QuickSort Worst Case Big O

O(n²)

28
New cards

QuickSort: Stable?

No

29
New cards

QuickSort: Adaptable?

No

30
New cards

QuickSort: In/out of place?

In

31
New cards

QuickSelect Best Case Big O

O(n)

32
New cards

QuickSelect Average Case Big O

O(n)

33
New cards

QuickSelect Worst Case Big O

O(n²)

34
New cards

QuickSelect: Stable?

No

35
New cards

QuickSelect: In/out of place

In

36
New cards

QuickSelect: Adaptable?

Trick Question!! Adaptability only applies to sorting algorithms and this isn't a sorting algorithm.

37
New cards

MergeSort Best Case Big O

O(n log n)

38
New cards

MergeSort Average Case Big O

O(n log n)

39
New cards

MergeSort Worst Case Big O

O(n log n)

40
New cards

MergeSort: Stable?

Yes

41
New cards

MergeSort: Adaptable?

No

42
New cards

MergeSort: In/out of place?

Out

43
New cards

HeapSort Best Case Big O

O(n log n)

44
New cards

HeapSort Average Case Big O

O(n log n)

45
New cards

HeapSort Worst Case Big O

O(n log n)

46
New cards

HeapSort: Stable?

No

47
New cards

HeapSort: Adaptable?

No

48
New cards

HeapSort: In/out of place?

Out

49
New cards

LSD Radix Sort Best Case Big O

O(kn)

50
New cards

LSD Radix Sort Average Case Big O

O(kn)

51
New cards

LSD Radix Sort Worst Case Big O

O(kn)

52
New cards

LSD Radix Sort: Stable?

Yes

53
New cards

LSD Radix Sort: Adaptable?

No

54
New cards

LSD Radix Sort: In/out of place?

Out

55
New cards

Brute Force Best Case Big O

O(m)

56
New cards

Brute Force Best Case Big O - no match

O(n)

57
New cards

AVL Tree Insertion, Search, and Deletion Best Case Big O

Insertion - O(log n)

Search - O(1)

Deletion - O(log n)

58
New cards

AVL Tree Insertion, Search, and Deletion Average Case Big O

O(log n)

59
New cards

Balanced AVL Tree Insertion, Search, and Deletion Worst Case Big O

O(log n)

60
New cards

Brute Force Average Case Big O

O(mn)

61
New cards

Brute Force Worst Case Big O

O(mn)

62
New cards

Unbalanced AVL Tree Insertion, Search, and Deletion Worst Case Big O

O(n)

63
New cards

Last Occurrence Table Creation Best Case Big O

O(m)

64
New cards

Last Occurrence Table Creation Average Case Big O

O(m)

65
New cards

Last Occurrence Table Creation Worst Case Big O

O(m)

66
New cards

BoyerMoore Best Case Big O - All occurrences

O(m + n/m)

67
New cards

BoyerMoore Best Case Big O -Single occurrence

O(m)

68
New cards

BoyerMoore Worst Case Big O - All occurrences

O(mn)

69
New cards

BoyerMoore Average Case Big O - All occurrences

O(m + n)

70
New cards

Failure Table Creation Best Case Big O

O(m)

71
New cards

Failure Table Creation Average Case Big O

O(m)

72
New cards

Failure Table Creation Worst Case Big O

O(m)

73
New cards

KMP Main Algorithm Big O

O(n)

74
New cards

KMP Best Case Big O - Single Occurrence

O(m)

75
New cards

KMP Best Case Big O - All Occurrences

O(m + n)

76
New cards

KMP Worst Case Big O

Failure Table Creation - O(m)

Main Algorithm - O(n)

So, the worst case is:

O(m + n)

77
New cards

Rabin-Karp Best Case Big O - All Occurrences

Calculating Initial Hashes - O(m)

Searching and Updating - O(n)

So, the best case is:

O(m + n)

78
New cards

Rabin-Karp Best Case Big O - Single Occurrence

O(m)

79
New cards

Rabin-Karp Worst Case Big O

O(mn)

80
New cards

BoyerMoore Galil Rule Best Case Big O

O(n/m)

81
New cards

BoyerMoore Galil Rule Average Case Big O

O(n)

82
New cards
83
New cards

BoyerMoore Galil Rule Worst Case Big O

O(n + m)

84
New cards

Linear probobing (Hashmap) Insertion, Search, and Deletion Best Case Big O

O(1)

85
New cards

Linear probobing (Hashmap) Insertion, Search, and Deletion Average Case Big O

O(1/(1-LF))

Current Load Factor, not MAX load factor

86
New cards

Linear probobing (Hashmap) Insertion, Search, and Deletion Worst Case Big O

O(n)

87
New cards

In-Place Sorts Definition

This means that the elements in the array passed in SHOULD NOT get copied over to another data structure.

Note that you can still create variables that hold only one item, but you cannot create another data structure such as an array or list in the method.

PS. Out of place Sorts just means the opposite of in place Sorts.

88
New cards

Stable Sorts Definition

This means that duplicates must remain in the same relative positions after sorting as they were before sorting. Basically, saying that they are not interchangeable cuz they are duplicates and need to keep their greater or less than status before sorting, through out sorting, and after sorting.

Ex: say we have a list = [1,5a,2,4,3,5b,8, 6,7]. Disclaimer: the letters on the 5’s are just to show they are different and the letters are not actually present in the array.

Before Sorting: [1,5a,2,4,3,5b,8,6,7].

After Sorting : [1,2,3,4,5a,5b,6,7,8]

89
New cards

Adaptive Sorts Definition

This means that the algorithm takes advantage of existing order in the input array by not comparing elements that are already ordered/relatively sorted.

90
New cards

Right Rotation Requirements

  1. Parent node balance factor is 2

  2. Heavier Child: Left

  3. Child balance factor is 1,0.

  4. Rotation Shape is a branch of three nodes facing right.

91
New cards

AVL Left-Right Rotation Requirements

  1. Parent node balance factor is 2.

  2. Heavier Child: Left

  3. Child balance factor is -1

  4. Rotation Shape looks like a greater than symbol created by connecting three nodes.

92
New cards

AVL Left Rotation Requirements

  1. Parent node balance factor is -2.

  2. Heavier Child: Right

  3. Child balance factor is -1, 0.

  4. Rotation Shape is a branch of three nodes facing left.

93
New cards

AVL Right-Left Rotation Requirements

  1. Parent node balance factor is -2.

  2. Heavier Child: Right

  3. Child balance factor is 1.

  4. Rotation Shape looks like a less than symbol created by connecting three nodes.

94
New cards