Below you will find pages that utilize the taxonomy term “Sorting”
December 1, 2016
Heapsort algorithm (Java)
Heapsort algorithm details: Worst-case Time Complexity: O(n log(n))
Space Complexity: O(1)
The algorithm The heapsort algorithm is an in-place, comparison based sorting algorithm. In the core of the algorithm (as the name suggest), the use of the heap data structure is improving the time complexity. In a nutshell, heap is a special type of tree, where the elements in the tree are in a certain order to each other. This allows to find the minimum or maximum of binary heap in O(1) and insertion/deletion in O(log(n)).
November 16, 2016
Merge sort algorithm (Java)
Merge sort algorithm details: Worst-case Time Complexity: O(n log(n))
Space Complexity: O()
The algorithm Merge sort is comparison based algorithm, from the efficient sorting category. The algorithm is based on “Divide and conquer” (John Van Neumann), which means in this case, that the original collection is divided into smaller chunks. This idea can be implemented in a recursive fashion, so that the collection is divided into single elements and then re-constructed into a sorted collection.
November 14, 2016
Bubble sort algorithm (Java)
Algorithm details: Worst-case Time Complexity: O(n^2)
Space Complexity: O(1)
The algorithm Bubble sort is a very simple sorting algorithm, with straight forward implementation. The algorithm is based on comparison of all elements to each other. The compared element positions are switched on the comparison result, and the element is shifted to the correct location. This implies, that each element has to be checked against each other. This results in n*n comparisons, even if the collection is in order.