Sorting Algorithms to Know for AP Computer Science A

studied byStudied by 2 people
5.0(1)
Get a hint
Hint

Bubble Sort

1 / 21

flashcard set

Earn XP

Description and Tags

22 Terms

1

Bubble Sort

A sorting algorithm that iteratively compares adjacent elements and swaps them if the first is greater than the second.

New cards
2

Best Case Time Complexity of Bubble Sort

O(n), occurs when the list is already sorted.

New cards
3

Average Case Time Complexity of Bubble Sort

O(n^2), occurs in most cases where elements are in random order.

New cards
4

Worst Case Time Complexity of Bubble Sort

O(n^2), happens when the list is sorted in reverse order.

New cards
5

Selection Sort

A sorting algorithm that finds the minimum (or maximum) element from the unsorted portion and swaps it with the first unsorted element.

New cards
6

Time Complexity of Selection Sort

O(n^2) for all cases, which makes it inefficient for large datasets.

New cards
7

Space Efficiency of Selection Sort

An in-place algorithm that requires no additional memory.

New cards
8

Insertion Sort

A sorting algorithm that builds the sorted list by inserting elements into their correct position one at a time.

New cards
9

Best Case Performance of Insertion Sort

O(n) when the input list is already sorted.

New cards
10

Average Case Complexity of Insertion Sort

O(n^2) when elements are in random order.

New cards
11

Merge Sort

A divide and conquer sorting algorithm that recursively divides the list into halves and merges sorted sublists.

New cards
12

Guaranteed Time Complexity of Merge Sort

O(n log n) in all cases (best, average, worst).

New cards
13

Stability of Merge Sort

Maintains the relative order of equal elements, making it a stable sorting algorithm.

New cards
14

Quick Sort

A sorting algorithm that selects a pivot and partitions the list around it, sorting elements recursively.

New cards
15

Average Case Time Complexity of Quick Sort

O(n log n), occurs with a good choice of pivots.

New cards
16

Worst Case Time Complexity of Quick Sort

O(n^2), occurs if the pivot is the smallest or largest element.

New cards
17

In-Place Sorting in Quick Sort

Requires minimal extra memory, making it more space-efficient compared to merge sort.

New cards
18

Unstable Sorting Algorithm

Quick Sort is an unstable algorithm as it does not preserve the relative order of equal elements.

New cards
19

Gradual Reduction in Bubble Sort

With each pass, the number of elements to compare decreases as the last elements become sorted.

New cards
20

Shifting Elements in Insertion Sort

During insertion, larger elements are shifted one position to the right to accommodate the current element.

New cards
21

Space Complexity of Merge Sort

Requires O(n) additional space for temporary storage when merging.

New cards
22

Sorted/Unsorted Division in Selection Sort

Expands the sorted portion of the list by moving the boundary after each minimum element is swapped.

New cards

Explore top notes

note Note
studied byStudied by 28 people
... ago
5.0(2)
note Note
studied byStudied by 3 people
... ago
5.0(1)
note Note
studied byStudied by 7 people
... ago
5.0(1)
note Note
studied byStudied by 16 people
... ago
5.0(1)
note Note
studied byStudied by 4 people
... ago
5.0(1)
note Note
studied byStudied by 27 people
... ago
5.0(1)
note Note
studied byStudied by 34 people
... ago
5.0(1)
note Note
studied byStudied by 118 people
... ago
5.0(1)

Explore top flashcards

flashcards Flashcard (21)
studied byStudied by 2 people
... ago
5.0(1)
flashcards Flashcard (265)
studied byStudied by 19 people
... ago
4.0(1)
flashcards Flashcard (24)
studied byStudied by 51 people
... ago
5.0(1)
flashcards Flashcard (46)
studied byStudied by 34 people
... ago
5.0(1)
flashcards Flashcard (23)
studied byStudied by 23 people
... ago
5.0(4)
flashcards Flashcard (53)
studied byStudied by 26 people
... ago
5.0(1)
flashcards Flashcard (30)
studied byStudied by 45 people
... ago
5.0(1)
flashcards Flashcard (25)
studied byStudied by 17 people
... ago
5.0(1)
robot