Docsity

Sorting Algorithms | CS 1044 - Intro Prog in C, Quizzes of Computer Science

Toggle sidebar
bg1
TERM 1
Bubble Sort
DEFINITION 1
Bubble sort is a simple sorting algorithm . It works by repeatedly
stepping through the list to be sorted, comparing two items at a
time and swapping them if they are i n the wrong order. The pass
through the list is repeated until no sw aps are needed, which
indicates that the list is sorted. The a lgorithm gets its name from
the way smaller elements "bubble" t o the top of the list. Because
it only uses comparisons to operate o n elements, it is a
comparison sort.
TERM 2
Quick Sort
DEFINITION 2
Quicksort is a well-known sorting algo rithm developed by C. A. R.
Hoare that, on average, makes (nlog n) (big O notation)
comparisons to sort n items. Howeve r, in the worst case, it makes
(n2) comparisons. Typically, quicksort is significantly faster in
practice than other (nlogn) algorithm s, because its inner loop can
be efficiently implemented on most a rchitectures, and in most
real-world data, it is possible to make d esign choices which
minimize the probability of requiring qu adratic time.
TERM 3
Insertion Sort
DEFINITION 3
Insertion sort is a simple sorting algorith m that is relatively
efficient for small lists and mostly-sorte d lists, and often is used as
part of more sophisticated algorithms. It works by taking elements
from the list one by one and inserting them in their correct
position into a new sorted list. In arrays , the new list and the
remaining elements can share the a rray's space, but insertion is
expensive, requiring shifting all followin g elements over by one.
Shell sort (see below) is a variant of ins ertion sor
TERM 4
Heap Sort
DEFINITION 4
Heapsort is a much more efficient ve rsion of selection sort. It also
works by determining the largest (or s mallest) element of the list,
placing that at the end (or beginning) of the list, then continuing
with the rest of the list, but accompli shes this task efficiently by
using a data structure called a heap, a special type of binary tree.
Once the data list has been made in to a heap, the root node is
guaranteed to be the largest(or sma llest) element.
TERM 5
Radix sort
DEFINITION 5
In computer science, radix sort is a so rting algorithm that sorts
integers by processing individual digits. Because integers can
represent strings of characters (e.g., names or dates) and specially
formatted floating point numbers, rad ix sort is not limited to
integers. Radix sort dates back as far as 1887 to the work of
Herman Hollerith on tabulating mach ines.
pf2

Partial preview of the text

Download Sorting Algorithms | CS 1044 - Intro Prog in C and more Quizzes Computer Science in PDF only on Docsity!

TERM 1

Bubble Sort

DEFINITION 1 Bubble sort is a simple sorting algorithm. It works by repeatedly stepping through the list to be sorted, comparing two items at a time and swapping them if they are in the wrong order. The pass through the list is repeated until no swaps are needed, which indicates that the list is sorted. The algorithm gets its name from the way smaller elements "bubble" to the top of the list. Because it only uses comparisons to operate on elements, it is a comparison sort. TERM 2

Quick Sort

DEFINITION 2 Quicksort is a well-known sorting algorithm developed by C. A. R. Hoare that, on average, makes (nlogn) (big O notation) comparisons to sort n items. However, in the worst case, it makes (n2) comparisons. Typically, quicksort is significantly faster in practice than other (nlogn) algorithms, because its inner loop can be efficiently implemented on most architectures, and in most real-world data, it is possible to make design choices which minimize the probability of requiring quadratic time. TERM 3

Insertion Sort

DEFINITION 3 Insertion sort is a simple sorting algorithm that is relatively efficient for small lists and mostly-sorted lists, and often is used as part of more sophisticated algorithms. It works by taking elements from the list one by one and inserting them in their correct position into a new sorted list. In arrays, the new list and the remaining elements can share the array's space, but insertion is expensive, requiring shifting all following elements over by one. Shell sort (see below) is a variant of insertion sor TERM 4

Heap Sort

DEFINITION 4 Heapsort is a much more efficient version of selection sort. It also works by determining the largest (or smallest) element of the list, placing that at the end (or beginning) of the list, then continuing with the rest of the list, but accomplishes this task efficiently by using a data structure called a heap, a special type of binary tree. Once the data list has been made into a heap, the root node is guaranteed to be the largest(or smallest) element. TERM 5

Radix sort

DEFINITION 5 In computer science, radix sort is a sorting algorithm that sorts integers by processing individual digits. Because integers can represent strings of characters (e.g., names or dates) and specially formatted floating point numbers, radix sort is not limited to integers. Radix sort dates back as far as 1887 to the work of Herman Hollerith on tabulating machines.