Sorting Algorithms for AP Computer Science A

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

1/33

flashcard set

Earn XP

Description and Tags

Sorting algorithms to know to AP CSA, includes best/worst runtime

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

34 Terms

1
New cards

Bubble Sort

A sorting algorithm that iteratively compares adjacent elements and swaps them if the first is greater than the second, allowing the largest unsorted element to 'bubble up' to its correct position.

2
New cards

Best Case of Bubble Sort

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

3
New cards

Average and Worst Case of Bubble Sort

O(n^2), occurs in cases where the list is in reverse order.

4
New cards

Selection Sort

A sorting algorithm that finds the smallest element from the unsorted portion of the list and swaps it with the first unsorted element.

5
New cards

Time Complexity of Selection Sort

O(n^2) comparisons in all cases, making it inefficient for large datasets.

6
New cards

Space Efficiency of Selection Sort

An in-place algorithm requiring no additional memory, making it suitable for memory-constrained environments.

7
New cards

Insertion Sort

A sorting method that processes elements one at a time, inserting each into its correct position in the sorted part of the list.

8
New cards

Shifting Elements in Insertion Sort

During insertion, larger elements in the sorted portion are shifted to the right to make space for the current element.

9
New cards

Best Case of Insertion Sort

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

10
New cards

Average and Worst Case of Insertion Sort

O(n^2), occurs for random or reverse-ordered data due to nested iterations.

11
New cards

In-Place and Stable

Characteristics of insertion sort that indicate it operates on the input list without extra memory and preserves the relative order of equal elements.

12
New cards

Merge Sort

A divide-and-conquer sorting algorithm that recursively divides the list into two halves and merges them in sorted order.

13
New cards

Time Complexity of Merge Sort

O(nlogn) in all cases (best, average, and worst).

14
New cards

Space Complexity of Merge Sort

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

15
New cards

Stable Sort

A sorting algorithm that maintains the relative order of equal elements, characteristic of merge sort.

16
New cards

Quick Sort

A sorting algorithm that uses partitioning to rearrange elements based on a pivot, such that elements less than the pivot are on one side and greater on the other.

17
New cards

Average and Best Case of Quick Sort

O(nlogn), occurs on average cases and best-case scenarios.

18
New cards

Worst Case of Quick Sort

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

19
New cards

In-Place Sorting

Refers to algorithms that require minimal extra memory, characteristic of quick sort.

20
New cards

Unstable Sort

A sorting algorithm that does not necessarily preserve the relative order of equal elements, like quick sort.

21
New cards

Iterative Insertion in Insertion Sort

The process of inserting each element into its appropriate position in a sorted list.

22
New cards

Pass Through the List in Bubble Sort

Refers to the process where the algorithm iteratively traverses the list to perform comparisons and swaps.

23
New cards

Finding Minimum in Selection Sort

The process of identifying the smallest element from the unsorted portion of the list during each pass.

24
New cards

Swapping in Selection Sort

The action of exchanging the smallest element with the first element of the unsorted portion of the list.

25
New cards

Sorted/Unsorted Division in Selection Sort

The method of expanding the sorted portion of the list one element at a time.

26
New cards

Divide and Conquer in Merge Sort

The strategy of recursively splitting the list into smaller parts until each contains a single element.

27
New cards

Merge Process in Merge Sort

Combining two sorted sublists into one sorted list by comparing and arranging elements.

28
New cards

Characteristics of Insertion Sort

In-place and stable algorithm effective for nearly sorted data.

29
New cards

Comparison in Algorithms

Refers to the process of evaluating pairs of elements to determine their order.

30
New cards

Best Use Cases of Bubble Sort

Best for small or nearly sorted datasets.

31
New cards

Best Use Cases of Selection Sort

Useful when memory space is limited and datasets are small.

32
New cards

Best Use Cases of Merge Sort

Ideal for large datasets requiring stability.

33
New cards

Best Use Cases of Quick Sort

Effective for large datasets where space is a concern.

34
New cards

Gradual Reduction in Bubble Sort

Fewer elements are compared in each pass as sorted elements accumulate at the end.