Sorting Algorithms Flashcards

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

1/11

flashcard set

Earn XP

Description and Tags

Flashcards covering sorting algorithms, including selection sort and insertion sort.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

12 Terms

1
New cards

What are some applications of sorting in data analysis?

Ranking answers to a web query, finding top scoring students, finding cheap airplane tickets, searching in a phone directory.

2
New cards

What is the input for the sorting problem?

A list/array of data in an arbitrary order.

3
New cards

What is the output for the sorting problem?

A list/array in a sorted order.

4
New cards

Why is sorting data fundamental to computational problems?

Ranking data, finding top X items, and enabling faster searching through binary search.

5
New cards

What are the basic steps of the selection sort algorithm?

Find the minimum value, add it to the sorted array, and remove it from the input array.

6
New cards

How does selection sort work in-place?

It finds the minimum value and moves it to the first index by swapping.

7
New cards

What is the invariant for selection sort correctness analysis?

At the end of phase i, the first i+1 entries of the array are sorted and contain the minimum i+1 values.

8
New cards

What is the worst-case time complexity of selection sort?

O(n^2)

9
New cards

What are the basic steps of the insertion sort algorithm?

Insert the first value into the sorted array and take the first value from the input array.

10
New cards

What is the invariant for insertion sort correctness analysis?

The first i+1 entries of the array are sorted (in increasing order).

11
New cards

What is the worst-case time complexity of insertion sort?

O(n^2)

12
New cards

How does insertion sort work in-place?

Inserting the values into a sorted sub-array.