Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Apply - Create a Table of Sorting Algorithms

DAT/305: Data Structures For Problem Solving

SORTING DEFINITION BENEFITS USES


ALGORITHMS
Bubble Sort Sorting algorithm Due to its Best used when
that works by simplicity, bubble data is small.
repeatedly sort is used to
swapping the introduce the
adjacent elements concept of a
if they are in the sorting algorithm
wrong order

is a simple sorting The insertion sort Insertion sort is


Insertion Sort algorithm that is an in-place used when the
works the way we sorting algorithm number of
sort playing cards so the space elements is small.
in our hands. requirement is
minimal

Quick Sort It picks an element Quick sort is one of Used for sorting
as pivot and the best sorting arrays
partitions the given algorithms
array around the because it is able
picked pivot. to deal well with a
huge list of items
and because it
sorts in place, no
additional storage
is required as well.

Merge Sort It divides input Merge sort is more Merge Sort is


array in two efficient and works useful for sorting
halves, calls itself faster than quick linked lists in
for the two halves sort in case of O(nLogn) time.In
and then merges larger array size or the case of linked
the two sorted datasets. lists, the case is
halves. different mainly
due to the
difference in
memory allocation
of arrays and
linked lists.

Bubble sort is a sorting algorithm that iterates through a list, comparing and
swapping adjacent elements if the second element is less than the first element.
Bubble sort uses nested loops. Given a list with N elements, the outer i-loop iterates
N times. Each iteration moves the ith largest element into sorted position. The inner
j-loop iterates through all adjacent pairs, comparing and swapping adjacent elements
as needed, except for the last i pairs that are already in the correct position,.

Insertion sort is a simple sorting algorithm that builds the final sorted array (or list)
one item at a time. It is much less efficient on large lists than more advanced
algorithms such as quicksort, heapsort, or merge sort.

Quick sort is a sorting algorithm that repeatedly partitions the input into low and high
parts (each part unsorted), and then recursively sorts each of those parts. To
partition the input, quicksort chooses a pivot to divide the data into low and high
parts. The pivot can be any value within the array being sorted, commonly the value
of the middle array element. Ex: For the list (4, 34, 10, 25, 1), the middle element is
located at index 2 (the middle of indices 0..4) and has a value of 10.

Merge sort is a sorting algorithm that divides a list into two halves, recursively sorts
each half, and then merges the sorted halves to produce a sorted list. The recursive
partitioning continues until a list of 1 element is reached, as list of 1 element is
already sorted.

You might also like