Sorting Algorithms

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

1/13

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

14 Terms

1
New cards

Insertion Sort

Sorts a list by placing each element in the position it should be in and gradually adding more elements one by one., A sort in which each item in a set is inserted into its proper position in the sorted set according to a specified criterion.

2
New cards

Selection Sort

Sorts a list by searching for the 1st element, then the 2nd, and so on until all the elements are in place., A sort in which the items in a set are examined to find an item that fits specified criteria. This item is appended to the sorted set and removed from further consideration, and the process is repeated until all items are in the sorted set.

3
New cards

Bubble Sort

A sort in which the first two items to be sorted are examined and exchanged if necessary to place them in the specified order; the second item is then compared with the third (exchanging them if required), the third is compared with the fourth, and the process is repeated until all pairs have been examined and all items are in the proper sequence.

4
New cards

Quicksort

A sort in which a list is first partitioned into lower and upper sublists for which all keys are, respectively, less than some pivot key or greater than the pivot key. See also the definitions for "bubble sort", "selection sort" and "insertion sort".

5
New cards

Mergesort

Splits the list into sub-lists and then reconstructs the original list.

6
New cards

Heap sort

This algorithm is based on the heap data structure, and is a more efficient version of selection sort. It determines the largest element. Then, it places that element at the end (or beginning) of the list, and then repeats the process with the rest of the list Recall that in a heap, the top element of the heap is always "next" in order (either the next highest or next lowest, in the case of numbers). If you were to take all of your input values and store them in a heap, and remove one element at a time, the elements will be removed in sorted order. Depending on the data list being sorted, this could have performance consequences. Heap sort is considered an "instable" sort because it doesn't preserve the original order of equal elements.

7
New cards

Stable sort

Any sort method that does not change the order of equal-rank elements.

8
New cards

Comparison sort

A sort that ranks items by comparing them to each other. As opposed to a sort that uses some other method, like the radix sort that analyzes the bits of each number.

9
New cards

Insertion sort time complexity

O(n^2) worst case, O(n) best case

10
New cards

Heap sort time complexity

O(n log n) in all cases

11
New cards

Quicksort time complexity

O(n^2) in the very unlikely worst case, O(n log n) in other cases

12
New cards

Selection sort time complexity

O(n^2) in all cases

13
New cards

Bubble sort time complexity

O(n^2) worst case, O(n) best case

14
New cards

Mergesort time complexity

O(n log n) in all cases