2.3.3 - Sorting Algorithms Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What is the purpose of a sorting algorithm?

A

They are designed to take a number of elements in any order and output them in a logical order.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the four sorting algorithms?

A

Bubble sort

Insertion sort

Merge sort

Quick sort

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How does a bubble sort work?

A

A bubble sort makes comparisons and swaps between pairs of elements.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the time complexity of the bubble sort algorithm?

A

O (n2).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How does an insertion sort work?

A

The insertion sort places elements into a sorted sequence.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the time complexity of an insertion sort?

A

O (n2).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How does a merge sort work?

A

A merge sort splits the data into lists of size one and then merges them together in order. It is a divide and conquer algorithm.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the time complexity of a merge sort algorithm?

A

O (n log n)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How does a quick sort work?

A

A quick sort works by selecting a pivot and sorting the list by comparing it to the pivot.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the time complexity of the quick sort algorithm?

A

O (n2).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly