list common sorting algorithms and recap how each works
- User
list common sorting algorithms and recap how each works
Assistant
Here's a list of common sorting algorithms, each with a one-sentence recap of how it works:
- Bubble Sort: It repeatedly steps through the list, compares adjacent elements, and swaps them if they are in the wrong order, causing larger elements to "bubble" to the end.
- Selection Sort: It repeatedly finds the minimum element from the unsorted part of the list and swaps it with the first unsorted element, gradually building a sorted section from the beginning.
- Insertion Sort: It builds the final sorted array one item at a time by taking each element from the unsorted input and inserting it into its correct position within the already sorted part of the array.
- Merge Sort: 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 sorted list remaining.
- Quick Sort: It picks an element as a "pivot" and partitions the other elements into two sub-arrays, according to whether they are less than or greater than the pivot, then recursively sorts the sub-arrays.
- Heap Sort: It builds a max-heap (or min-heap) from the input data, then repeatedly extracts the largest (or smallest) element from the heap and places it at the end (or beginning) of the sorted portion of the array.
- Radix Sort: It sorts numbers by processing individual digits (or bits) from least significant to most significant (or vice-versa), using a stable sorting algorithm for each digit pass.
- Counting Sort: It sorts elements by counting the number of occurrences of each distinct element and then uses that count information to place each element into its correct sorted position in an output array.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.