Sorting Algorithms: Selection and Insertion Sort Key Concepts and Code

0.0(0)
studied byStudied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/8

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 7:06 PM on 12/10/25
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

9 Terms

1
New cards

An algorithm that sorts an array swaps _____.

two elements at a time

2
New cards

Which is sorted into ascending order?

Sally, Sam, Sandy, Samantha, Sal

Ral, Reece, Rita, Ryan

Don, Dan, Dale, Dana

Alan, Andy, Al, Adam

Ral, Reece, Rita, Ryan

3
New cards

Which of the following is not an example of sorting?

Arranging patient records alphabetically

Arranging employee details based on beginning dates

Arranging student records neatly on a desk

Arranging musical instruments based on the number of strings they have

Arranging student records neatly on a desk

4
New cards

In selection sort, the smallest element is selected and swapped with the _____ unsorted element.

leftmost

5
New cards

The array [67, 23, 32, 80, 53, 60] is to be sorted using selection sort. What is the order of the elements after the third swap?

23, 32, 53, 80, 67, 60

6
New cards

What statement must replace the XXX to complete the selection sort algorithm below?

void selectionSort(int[] numbers) { for (int i = 0; i < numbers.length - 1; i++) { int indexSmallest = i; for (int j = i + 1; j < numbers.length; j++) { if (numbers[j] < numbers[indexSmallest]) { indexSmallest = j; } } int temp = numbers[i]; XXX numbers[indexSmallest] = temp; } }

numbers[i] = numbers[indexSmallest];

7
New cards

Given the array [77, 75, 70, 50, 10], what is the order of the elements after completing insertion sort's second outer loop iteration?

70, 75, 77, 50, 10

8
New cards

What replaces XXX to complete the insertion sort algorithm?

for (int i = 1; i < numbers.length; i++) { int j = i; XXX { int temp = numbers[j]; numbers[j] = numbers[j - 1]; numbers[j - 1] = temp; j--; } }

while (j > 0 && numbers[j] < numbers[j - 1])

9
New cards

What is the SMALLEST number of swaps that insertion sort may perform when sorting 20 elements?

0

Explore top flashcards

Onc lec 3
Updated 435d ago
flashcards Flashcards (112)
SAT Vocab Lesson 7-8
Updated 321d ago
flashcards Flashcards (30)
Uni
Updated 450d ago
flashcards Flashcards (42)
POS lesson 15
Updated 1074d ago
flashcards Flashcards (29)
Festival Neck Pain
Updated 1099d ago
flashcards Flashcards (81)
Unit 5: Hereditary
Updated 1044d ago
flashcards Flashcards (62)
Onc lec 3
Updated 435d ago
flashcards Flashcards (112)
SAT Vocab Lesson 7-8
Updated 321d ago
flashcards Flashcards (30)
Uni
Updated 450d ago
flashcards Flashcards (42)
POS lesson 15
Updated 1074d ago
flashcards Flashcards (29)
Festival Neck Pain
Updated 1099d ago
flashcards Flashcards (81)
Unit 5: Hereditary
Updated 1044d ago
flashcards Flashcards (62)