zuai-logo
zuai-logo
  1. AP Computer Science A
FlashcardFlashcard
Study GuideStudy GuideQuestion BankQuestion Bank

What is Selection Sort?

A sorting algorithm that divides the list into sorted and unsorted subarrays, repeatedly finding the minimum element from the unsorted subarray and placing it at the beginning.

Flip to see [answer/question]
Flip to see [answer/question]
Revise later
SpaceTo flip
If confident

All Flashcards

What is Selection Sort?

A sorting algorithm that divides the list into sorted and unsorted subarrays, repeatedly finding the minimum element from the unsorted subarray and placing it at the beginning.

What is Insertion Sort?

A sorting algorithm that builds the final sorted array one item at a time by repeatedly inserting elements from the unsorted portion into the correct position in the sorted portion.

What is an ArrayList?

A resizable array implementation of the List interface.

What is a sorted array?

An array where elements are arranged in a specific order (ascending or descending).

What is a subarray?

A contiguous part of an array.

What is ascending order?

Arrangement from smallest to largest.

What is descending order?

Arrangement from largest to smallest.

What is swapping?

Exchanging the positions of two elements in an array.

What is an algorithm?

A step-by-step procedure for solving a problem.

What is run-time comparison?

Evaluating the efficiency of algorithms by counting statement executions.

What are the differences between Selection Sort and Insertion Sort?

Selection Sort: Finds the minimum element and swaps. | Insertion Sort: Inserts elements into the sorted portion.

Selection Sort vs. Insertion Sort: Data Accesses

Selection Sort: Requires more data accesses and modifications. | Insertion Sort: Requires fewer data accesses and modifications.

Selection Sort vs. Insertion Sort: Best case scenario

Selection Sort: Performance not affected by input. | Insertion Sort: More efficient when data is partially sorted.

Selection Sort vs. Insertion Sort: Implementation Complexity

Selection Sort: Generally simpler to implement. | Insertion Sort: Slightly more complex due to shifting elements.

Selection Sort vs. Insertion Sort: Performance on small datasets

Selection Sort: Performance is generally consistent. | Insertion Sort: Can be faster for small, nearly sorted datasets.

Selection Sort vs. Insertion Sort: Number of swaps

Selection Sort: Performs fewer swaps. | Insertion Sort: Performs more swaps.

Selection Sort vs. Insertion Sort: Adaptability

Selection Sort: Not adaptive (doesn't take advantage of existing order). | Insertion Sort: Adaptive (performs better on nearly sorted data).

Selection Sort vs. Insertion Sort: Use cases

Selection Sort: Suitable for small datasets where minimizing writes is important. | Insertion Sort: Suitable for small datasets or when data is nearly sorted.

Selection Sort vs. Insertion Sort: Worst-case time complexity

Selection Sort: O(n^2). | Insertion Sort: O(n^2).

Selection Sort vs. Insertion Sort: Space complexity

Selection Sort: O(1). | Insertion Sort: O(1).

What is the core idea behind Selection Sort?

Repeatedly selecting the smallest element and moving it to the sorted portion.

What is the core idea behind Insertion Sort?

Building a sorted subarray by inserting elements from the unsorted portion into their correct positions.

How do you determine if an ArrayList is sorted?

Iterate through the list, checking if each element is less than or equal to the next.

What is the purpose of sorting algorithms?

To arrange elements in a specific order, typically ascending or descending, for easier searching and data retrieval.

What is the significance of run-time comparisons?

They help in understanding the efficiency of different algorithms and choosing the best one for a specific task.

What are the two subarrays in Selection Sort?

Sorted subarray and unsorted subarray.

What are the two subarrays in Insertion Sort?

Sorted subarray and unsorted subarray.

Why is it important to check if an ArrayList is sorted?

To ensure data integrity and efficiency in search and retrieval operations.

What is the main goal of comparing sorting algorithms?

To understand their relative efficiency and choose the best one for a given situation.

What is the role of swapping in sorting algorithms?

To rearrange elements in the correct order.