Sorting Algorithms Flashcards

1
Q

Sorting Algorithms

A

Sorting algorithms are methods for arranging elements in a specific order, typically in ascending or descending order. Common sorting algorithms include Quick Sort, Merge Sort, Bubble Sort, and Insertion Sort.

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

Quick Sort

A

Quick Sort is a highly efficient, in-place, and divide-and-conquer sorting algorithm. It works by selecting a ‘pivot’ element from the array and partitioning the other elements into two sub-arrays, according to whether they are less than or greater than the pivot. The sub-arrays are then recursively sorted.

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

Merge Sort

A

Merge Sort is a stable and efficient sorting algorithm that uses a divide-and-conquer approach. It divides the unsorted list into n sublists, each containing one element, and then repeatedly merges sublists to produce new sorted sublists until there is only one sublist remaining, which is the sorted list.

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

Bubble Sort

A

Bubble Sort is a simple sorting algorithm that repeatedly steps through the list, compares adjacent elements, and swaps them if they are in the wrong order. The pass through the list is repeated until no swaps are needed, indicating that the list is sorted.

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

Insertion Sort

A

Insertion Sort is a simple sorting algorithm that builds the final sorted array one item at a time. It works by repeatedly taking an unsorted element and inserting it into its correct position within the sorted part of the array. It has a time complexity of O(n^2) on average but performs well for small datasets.

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