DAT/305: Data Structures For Problem Solving
DAT/305: Data Structures For Problem Solving
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.
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.