[go: up one dir, main page]

0% found this document useful (0 votes)
274 views28 pages

ALG Part1 ASSIGNMENT

The document discusses sorting algorithms and provides details about merge sort and heap sort. It begins with an overview of sorting as a fundamental problem in computer science. Next, it provides a example problem of sorting expense documents from oldest to latest by date. It then describes merge sort, including its introduction, steps, and an example code snippet. Finally, it discusses heap sort, including its introduction, diagrams of max and min heaps, and that it sorts in place using a heap data structure.

Uploaded by

hdsasdad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
274 views28 pages

ALG Part1 ASSIGNMENT

The document discusses sorting algorithms and provides details about merge sort and heap sort. It begins with an overview of sorting as a fundamental problem in computer science. Next, it provides a example problem of sorting expense documents from oldest to latest by date. It then describes merge sort, including its introduction, steps, and an example code snippet. Finally, it discusses heap sort, including its introduction, diagrams of max and min heaps, and that it sorts in place using a heap data structure.

Uploaded by

hdsasdad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

Cover Page

Part A: Algorithm and Complexity

1.0 Problem Chosen - Sorting (250 Words)

Explain a problem in layman term

The ordering of list elements is a fundamental problem in computer science. Despite


the large number of sorting algorithms available, the sorting problem has drawn a lot of
attention since effective sorting is critical for optimising the use of other algorithms. (Gaurav
K., 2014) A Sorting Algorithm rearranges the members of an array or list based on a
comparison operator on the elements. In the respective data structure, the comparison
operator is employed to determine the new order of elements. (Sorting Algorithms, 2021) The
types of sorting algorithms included quick sort, merge sort, bubble sort, insertion sort,
selection sort, heap sort, radix sort and bucket sort.

By implementing sorting algorithms, it is able to reorganise a huge number of things


into a specific order, such as from highest to lowest, alphabetically or even vice versa. These
algorithms take input lists, process them, apply operations on them, and return sorted lists.
The most common example we see on a daily basis is categorising clothes or other things on
an e-commerce website from lowest to highest price, or popularity, or in some other order.
(Types of Sorting Algorithms, n.d.) A sorting algorithm is used by search engines. When you
search for a keyword on the internet, you will be presented with feedback information
arranged by the significance of the web page. (Akash k. 2014) The sorting algorithms have
been extensively studied. In addition to the search engines mentioned above, the sorting
algorithm has also been used in many applications, including operating systems, real time
systems and discrete event simulation. (Gaurav K., 2014)

Below is an example of a sorting algorithm problem in order to understand and be


able to use in daily life. Mary is an accounting intern in Mode Company, today she has been
assigned a task to sort the document of the expenses of the sales department from August to
October, arrange the orders according to the date of the document from oldest to latest. At
first, Mary collected all of the receipts from August to October because she needed to take
the list of the receipts and start to arrange according to the date. Mary starts sorting the
document by months, she has divided the document to August, September and October in
three parts. In addition, Mary divided each part and arranged according to the days, from
oldest to latest. At the end, Mary combined each three parts together and completed sorting
the documentation according to the date.
2.0 Algorithm Chosen

2.1 Merge Sort (375 Words)

2.1.1 Introduction to Merge Sort

Merge is a sorting method that uses the conquer and divide method. Merge sort is
similar to rapid sort algorithm in that it sorts the elements using a divide and conquer
strategy. It’s one of the most widely used and effective sorting algorithms. In addition, by
implementing merge sort, it splits the given list into the 2 equal halves, then calls itself for
each half and merges the 2 sorted parts. (Merge Sort Algorithm, n.d) Moreover, the sub-lists
will be divided into halves again and again until the list can no longer be divided. The first
stage involves splitting the list into separate parts known as sub-lists. The ‘merge’ stage
begins after that. The sub-lists are matched up here and sorted in the order specified.
(Holamyself, 2019)

By implementing merge sort, for bigger lists, it is faster because, unlike bubble and
insertion sort, it does not traverse through the entire list many times. It has a regular running
time and performs different portions in a stage at similar times. (Holamyself, 2019)

2.1.2 Steps to do Merge Sort

An example will be given to represent the steps to sort an array using the Merge Sort
algorithm.
Figure 2.1.2 Merge Sort Process

Take an unsorted array as an example to better grasp the merge sort algorithm;s
operating principle. Merge sort is easier to grasp by using examples. The elements of the
example array are 12, 31, 25, 8, 32, 17, 40, 42. First, divide the provided array into 2 equal
halves according to the merging sort. The merge sort needs to divide the list into equal
portions until it can not be divided any further. The first step of dividing is to divide the 8
elements of the array into 2 arrays of size 4. Next, the array needs to be divided again into
halves, divide them into new arrays of size 2 because they are of size 4. After dividing into
arrays of size 2, divide these arrays once more to obtain the atomic value that can not be
divided any further. (Working on Merge Sort Algorithms, n.d)

After dividing until not able to be divided again, combine the elements as the same
ways they were broken. When merging arrays, compare the elements of each array first, then
merge them in sorted order into a new array. First, compare between 12 and 31, which are
both in sorted order. Then compare between 25 and 8, and place 8 first in the list of 2 values,
followed by 25. After that, compare between 32 and 17 and rank them so that 17 comes first.
After that, compare between 42 and 40 and arrange them in a logical order. Compare the
arrays containing 2 data values in the following iteration of combining and combine them in
sorted order into a set of found values. After final merging, the array order will be 8, 12, 17,
25, 31, 32, 40, 42. (Working on Merge Sort Algorithms, n.d)

2.1.3 Example of code snippet

class Merge {
void merge(int x[], intleft, int mid, int right)
{
int x, y, z;
int a1 = mid - right + 1;
int a2 = left - mid;

int LeftArr[] = new int [a1];


int Rightarr[] = new int [a2];

for(x=0; x<a1; x++)


LeftArr[x] = x[left + x];
for (y = 0; y< a2; y++)
RightArr[y] = a(mid + 1 + y];

x = 0;
y = 0;
z = left;

while(x < a1 && y < a2)


{
if(LeftArr[x] <= RightArr[y])
{
a[z] = LeftArr[x];
x++;
}
else
{
a[z] = RightArr[y];
y++;
}
z++;
}
while ( x < a1 )
{
a[z] = LeftArr[x];
x++;
z++;
}
while ( y < a2 )
{
a[z] = RightArr[y];
y++;
z++;
}
}

void mergeSort ( int a[]; int left, int right)


{
if(left < right)
{
int mid = ( left + right ) /2;
mergeSort(a, right, left);
mergeSort(a, mid + 1, right);
merge(a, left, mid, right);
}
}

void print(int a[], int n)


{
int x;
for (x = 0; x < n; x++)
System.out.print(a[x] + " ");
}

public static void main(String args[])


{
int a[] = { 11, 30, 24, 7, 31, 16, 39, 41 };
int n = a.length;
Merge m1 = new Merge();
System.out.println("\n unsort array elements are - ");
m1.printArray(a, n);
m1.mergeSort(a, 0, n - 1);
System.out.println("\n sort array elements are - ");
m1.printArray(a, n);
System.out.println("");
}

(Working on Merge Sort Algorithms, n.d)

2.2 Heap Sort (375 Words)

2.2.1 Introduction to Heap Sort

Heap Sort is one of the popular comparison-based sorting methods invented by J.W.J
Williams in 1964. (Kataria, 2018) It is an in-place algorithm that only requires a constant
amount of auxiliary memory at any time beyond the input as it sorts the array by swapping
the position of the elements within the original array. (Black & Martinez, 2019) The list of
elements to be sorted will be transformed into a Binary Heap data structure which refers to a
complete binary tree with heap properties. In a binary tree, each element of the array will be
represented as a node of the tree with the value stored in the node. Every node in the tree will
only have two descendants except leaves and be completely filled from the left up to a point.
The value of the parent node will be either greater or lesser than its child nodes. A Binary
Heap can be categorized into 2 types, which are Max Heap and Min Heap. A Max Heap
indicates the value of the root node must be greater than or equal to its children while the
value of the root node in a Min Heap must be lesser or equal to its children. The diagram
below shows an example of Max Heap and Min Heap. ("HeapSort - GeeksforGeeks", 2021)

Max Heap and Min Heap ("Heap Sort", n.d.)

In the Heap Sort algorithm, Max Heap will be used to sort the array in descending
order while Min Heap will be used to arrange the elements in the array ascendingly. ("Data
Structures Tutorials - Heap Sort Algorithm", n.d.) To sort an array by using Heap Sort
algorithms, the first phase is to create either a Max Heap or Min Heap depending on the
required order of the sorted array. The elements will be moved to its proper position
accordingly until it meets the heap property and this process is called Heapify. Once a heap
has been created, it comes to the second phase in which the root of the heap will be shifted to
the end node and the root element will be eliminated from the heap by moving it to the end of
the array. After removal, the heap will be heaped and the process in the second phase will be
repeated until all the elements are eliminated as well as the array is completely sorted. ("Heap
Sort Algorithm - InterviewBit", n.d.)
2.2.2 Steps to perform Heap Sort algorithm

An example will be given to represent the steps to sort an array using the Heap Sort
algorithm.

Assume the array to be rearranged consists of the elements: 3, 21, 18, 7, 9, 15, and the array
should be sorted in descending order. A binary tree will be created from the array elements.
In array-based representation, the element of index 0 will be the root element while the left
and right child of any element can be calculated by index 2*i+1 and 2*i +2. The array is
assumed to start at index 0. ("HeapSort - GeeksforGeeks", 2021) Based on the assumption,
the diagram below shows the array with its binary tree in visualization.

Unsorted Array and its Binary Tree Version

Phase 1: Create a Max Heap


A Max Heap will be built based on the binary tree created above. To create a Max Heap, the
parent elements should be greater or equal than its child elements. The parent element will be
swapped with its child if the element does not meet the requirement. The figure below
represents the steps to create a Max Heap.

Steps to Create Max Heap

Phase 2: Eliminate root element from the heap

In phase 2, the root element of the Max Heap will be eliminated by swapping it with the end
node of the heap. The removed element will be shifted to the end of the array. In array-based
representation, the element will be extracted from the heap by reducing the maximum array
index of the heap by 1. After that, the heap will be heaped. The whole step will be conducted
repeatedly until all the elements have been covered and sorted into the array while the size of
the heap is greater than 1 in array-based representation. ("Heap Sort Algorithm -
InterviewBit", n.d.) The figure below represents the eliminating and sorting process.
Eliminating and Sorting Process

2.2.3 Example of Code Snippet

The table below shows the implementation of the Heap Sort algorithm written in Java.

public class HeapSort {

public void sort(int arr[]) {


int n = arr.length;
// Build Max Heap
for (int i = n / 2 - 1; i >= 0; i--) {
heapify(arr, n, i);
}
// Heap Sort
for (int i = n - 1; i >= 0; i--) {
int temp = arr[0];
arr[0] = arr[i];
arr[i] = temp;
// Heapify Root Element
heapify(arr, i, arr[0]);
}
}

void heapify(int arr[], int n, int i) {


// Find largest among root, left child and right child
int largest = i;
int l = 2 * i + 1;
int r = 2 * i + 2;

if (l < n && arr[l] > arr[largest])


largest = l;
if (r < n && arr[r] > arr[largest])
largest = r;

// Swap and continue heapifying if root is not largest


if (largest != i) {
int swap = arr[i];
arr[i] = arr[largest];
arr[largest] = swap;
heapify(arr, n, largest);
}
}

// Function to print an array


static void printArray(int arr[]) {
int n = arr.length;
for (int i = 0; i < n; ++i)
System.out.print(arr[i] + " ");
System.out.println();
}

// Driver code
public static void main(String args[]) {
int arr[] = { 3, 21, 18, 7, 9, 15 };
HeapSort hs = new HeapSort();
hs.sort(arr);

System.out.println("Sorted array is");


printArray(arr);
}
}

Code Snippet of Heap Sort Algorithm ("Heap Sort", n.d.)


3.0 Complexity Analysis

3.1 Merge Sort (350 Words)

3.1.1 Time Complexity

Figures 3.1.1.1 Mergesort Function

Figures 3.1.1.2 Merge Function

Figures 3.1.1.3 Recursive Formula

Assume that we have n numbers in our unsorted input list. We have to apply the mergesort
function to the left half of the input array (size n/2), as well as the right half of the input array
(size n/2). The merge process does not contain any nested loops, so it is executed with linear
complexity. If the array size is doubled, the merge time doubles. Therefore, a running time of
O(n) will be required to merge the subarrays. So based on this we get a recursive formula, but
we still need to compute the number of steps used by merge. We compare two numbers and
shift one number to the result array, so there are two steps for each number. Hence, the
number of steps taken is 2n steps in total. ("Introduction to Recursion and Merge Sort", 2021)

Figures 3.1.1.4 Plug In the Formula Repeatedly

After that, we have to solve the recurrence formula. We can see that plugging in the formula
recursively k times gives us the formula as below.

Figures 3.1.1.5 Plugging In Formula Recursively k Times

Figures 3.1.1.6 K=log₂(n) Formula


With the above formula, we can know that K=log₂(n). Hence, we can plug in K=log₂(n) to the
above formula. If the input of the array size is 1, the function does nothing but output it as is
again. As a conclusion, we can know that the time complexity of merge sort is O(n*log n).

Figures 3.1.1.7 Plug In K=log₂(n)

3.1.2 Best Case

As merge sort algorithm will always divide the array into two halves and takes linear time to
merge two halves, so the time complexity of best case scenario is O(n*log n). However, it can
be improved if the number of comparisons can be reduced while doing merge and sort. In
order to achieve the minimum number of comparisons, the input array has to be ascending or
descending order. The example array will be [0,1,2,3,4,5,6,7]. As a result, merge sort is faster
than random data since the number of comparisons is reduced.

Figures 3.1.2.1 Example Array that Have Minimum Comparisons

3.1.3 Worst Case

The time complexity of worst case scenario is the same as the best case scenario which is
O(n*log n). This is because the merge sort divides the array in two halves at each stage,
giving it the log(n) component, while the other N component comes from the comparisons
made at each stage, whether the worst case or average scenario. As a result, combining it
becomes nearly O(n*log n). Whether it's the best-case scenario or the worst-case scenario, the
log(n) element is always present. And the rest n factor depends on the comparisons made,
which derive from both situations' comparisons. Therefore, the worst case of merge sort will
be the one where merge sort will have to do a maximum number of comparisons. The
example of the input array will be [4,0,6,2,5,1,7,3], where we can see that it has the
maximum number of comparisons. ("Introduction to Recursion and Merge Sort", 2021)

Input array arr[] = [4,0,6,2,5,1,7,3]


/ \
/ \
[4,0,6,2] and [5,1,7,3]
/\ /\
/ \ / \
[4,0] [6,2] [5,1] [7,3] Every pair of 2 will be compared at least once
therefore maximum comparison here
| | | |
| | | |
[0,4] [2,6] [1,5] [3,7] Maximum Comparison:Every pair of set is used in
comparison
\ / \ /
\ / \ /
[0,2,4,6] [1,3,5,7] Maximum comparison again: Every pair of set
compared
\ /
\ /
[0,1,2,3,4,5,6,7]
3.2 Heap Sort (350 Words)

3.2.1 Time Complexity

Time complexity of heap sort can be separately calculated by its two processes, which
are build max heap function and extract max function. Below table shows the time
complexity analysis for these two operations.

3.2.1.1 Build Max Heap

// Build Max Heap


public void buildMaxHeap(int[] arr, int n, int i) { -> 1
for (int i = n / 2 - 1; i >= 0; i--) { -> n/2+1
heapify(arr, n, i); -> n/2
}
}

Table 3.2.1.1 - Time Complexity of buildMaxHeap outer loop

Figure 3.2.1.1 - Count of comparison in buildMaxHeap’s heapify function


Total number of comparison in buildMaxHeap’s heapify function

= (0 * n/2) + (2 * n/4) + (4 * n/8) + (6 * n/16) + ...

= 2n(1/4 + 1/2 + 3/16 + ...)

= 2n * c (c is constant)

Table 3.2.1.2 - Heapify comparison analysis in buildMaxHeap function

The table 3.2.1.1 shows the time complexity of the buildMaxHeap function. It can see
that the outer loop will only execute n/2 times because it is not required to perform heapify
for leaf nodes. This is not the final time complexity because the heapify function will execute
recursively in a bubble down way. Therefore, a count of comparison for each level is shown
in the figure 3.2.1. Every heapify operation will perform two comparisons, one for choosing
the largest value among children and one for comparison with the parent’s value. The total
number of comparisons is counted in table 3.2.1.2 by summing all the comparisons at each
level. At last, the result for the example given is 2n * c, which c is a constant. Therefore, the
highest order of number of operations is n and it can be concluded that the time complexity of
the buildMaxHeap function is O(n).
3.2.1.2 Extract Max

//Extract Max
public void extraxtMax(int[] arr, int n, int i) { -> 1
for (int i = n - 1; i >= 0; i--) { -> n + 1
int temp = arr[0]; -> n
arr[0] = arr[i]; -> n
arr[i] = temp; -> n
heapify(arr, i, arr[0]); -> n
}
}

Table 3.2.1.3 - Time Complexity of extractMax outer loop

Total number of comparisons in extractMax’s heapify function

= 2*log(2) + 2*log(3) + 2*log(4) + ... + 2*log(n)

= 2 [log(2) + log(3) + log(4) + ... + log(n)]

= 2 [log(n!)] (Refer to Striling’s Formula at figure 3.2.1.2)

= 2 (nlog(n) - n + ½ log(n) + ½ log(2π) + εn)

= 2nlog(n) + log(n) + log(2π) - 2n + 2*εn

Table 3.2.1.4 - Heapify comparison analysis in extractMax function

Figure 3.2.1.2 - Striling’s Formula (conrad, 2017)


Table 3.2.1.3 shows the time complexity of the outer loop of extractMax function.
The outer loop will execute n times. The inner time complexity of the heapify function is
shown in table 3.2.1.4. The total number of comparisons in extractMax’s heapify function is
calculated by multiplying the two comparisons at every level with the level of the heap which
requires it to heapify in a bubble down way. From the result, it can be seen that the O(nlogn)
is the largest order and dominates the time complexity.

In conclusion, the time complexity of heap sort will always depend on the size of the
input array and the call of the heapify function in the algorithm. In the heap sort algorithm
the heapify can happen at two stages, the first stage is build max heap function and the
second stage is extract max function. The time complexities of build max heap and extract
max function are respectively O(n) and O(nlogn). Since O(nlogn) dominates the time
complexity, therefore, it only considers the heapify operation in extract max function when
calculating the overall time complexity.
3.2.2 Best Case

In order to achieve the best case, the call of heapify operations in extract max function
should be reduced to minimum. It can achieve the minimum call of n times when all the input
values are the same, which n is the input of array size. For example the input unsorted array is
[8, 8, 8, 8, 8, 8]. In this scenario, the heapify function will not be executed in a bubble down
way or in recursively. The heapify function will always execute exactly one time only when
the maximum value is extracted. Figure 3.2 shows the process of extracting the maximum
number stage in heap sort when the input values are identical.
Figure 3.2.2 - Eliminating and Sorting Process with Identical Input Array Values
Operation Count (n is the input array size)

Swap n times

Eliminate n times

Heapify n times (Every extraction only execute once)


Table 3.2.2 - Call counting of extract max function with Identical Input Array Values

From the figure 3.2, the process of extracting the maximum for identical input array
values can be seen. The heapify operation for each round of extracting will only execute
once. This is because the values of the child index are always the same with the parent value.
Therefore, it does not require heapify calling to maintain the max heap property and will not
recursively call the heapify again for its child. The total number of heapify function calls for
extract max function is n times instead of log n, which n is the number of input.

After the analysis above, it can be seen that the time complexity of heap sort can
actually reduce to linear time which is O(n) in the best case. The problem is the situation in
which all the input values are identical is unrealistic and impractical in the real world. That is
because nobody wants to sort an array with all the identical values. Therefore, this situation is
being ignored and the time complexity in the best case will still be maintained in O(nlogn)
where the input array’s values are not all identical.

3.2.3 Worst Case

Same with calculation of best case, since extract max function dominates the overall
time complexity, therefore, the worst case analysis only focuses on calculating the worst
scenario in the extract max function. The worst case happens when all the input is distinct
and it is required to perform a heapify function in a bubble down way for every call of extract
max process. To illustrate this, a perfect example is an input unsorted array with values [1, 2,
3, 4, 5, 6, 7, 8, 9]. After buildMaxHeap, it will become [9, 8, 7, 6, 5, 4, 3, 2, 1]. Everytime,
the maximum value is swapped with the minimum value at the last, it is required to compare
at every level until the bottom which will cause total time complexity of nlogn as discussed in
the section 3.1.1.2.
3.3 Suitability of Algorithms
· To explain which algorithms are most suitable in what scenarios, consider various
attributes

Size and volume of data


Desired speed of processing

3.3.1 Merge Sort


Merge sort is suitable for sorting linked lists in O(nlog n) time, because the memory
allocation of linked lists and arrays is different. Linked list nodes may not be adjacent in
memory. With using the linked list, we are able to insert items in the middle in O(1) extra
space and O(1) time. As a result, the merge sort operation can be accomplished without the
need of additional space for linked lists. We can do random access in an array since the
elements are contiguous in memory, but we can not do random access in the linked list.
Because a linked list does not contain a continuous block of memory, we must travel from the
head node to each and every node. Therefore, merge sort requires low random access and it
accesses the data sequentially. ("Merge Sort - GeeksforGeeks", 2021)
3.3.2 Heap Sort
Sorting a huge list of data
Heap sort is suitable for a large list of data. This is because its upper bound time
complexity only costs O(nlogn). If the dataset is small, there are some algorithms more
suitable for it such as bucket sort or counting sort, which can achieve linear time. But when
the dataset gets large, there can be disasters which may cause O(n^2) or even O(n^3) for
them. The overall time complexity of heapsort will not increase even if the input array is very
large, therefore it is very suitable for sorting a huge list of data.

Smallest and highest value is needed instantly


It can notice that heapsort will always be used when the smallest and highest value is
needed instantly. This is due to the property of heap which allows extracting either the
minimum value or the maximum value depending on the heap type in a constant time or
O(1). For example, Dijkstra’s algorithm can implement heap sort for finding the shortest path
and it also can be used to calculate the order in statistics or the job scheduling in the operating
system. (Sharma, 2020)

Does not require extra space


Heap sort is a sorting algorithm that can be implemented as an in-place algorithm
which means it does not require any additional space during the execution. The
buildMaxHeap function will build the heap by using the initial input array. Besides that, the
extractMax function will also use the same array for extracting and heapify. In contrast,
merge sort requires more extra space to work, which will require O(n) for the space
complexity. If space is a critical issue for the program, heap sort should be used because it is
able to save a ton of space in the runtime. (Wandy, 2019)
References
1. Sorting Algorithms ( 2021, July 31) Retrieved October 15, 2021, from
https://www.geeksforgeeks.org/sorting-algorithms/
2. Types of Sorting Algorithms ( n.d.) Retrieved October 15, 2021 from
https://www.interviewbit.com/tutorial/sorting-algorithms/
3. Akash K. (2014, December 11) Merge Sort Algorithm www.citeseerx.ist.psu.edu
Retrieved October 16, 2021 from
https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.845.6329&rep=rep1&type
=pdf
4. Introduction to Recursion and Merge Sort. Medium. (2021). Retrieved 16 October
2021, from
https://towardsdatascience.com/introduction-to-recursion-and-merge-sort-2e143b1b76
15.
5. HeapSort - GeeksforGeeks. GeeksforGeeks. (2021). Retrieved 17 October 2021, from
https://www.geeksforgeeks.org/heap-sort/.

6. Kataria, A. (2018). Heap Sort (Introduction, Algorithm and Program using C).
Includehelp.com. Retrieved 17 October 2021, from
https://www.includehelp.com/data-structure-tutorial/heap-sort-introducntion-algorith
m-

7. Black, P., & Martinez, C. (2019). in-place sort. Xlinux.nist.gov. Retrieved 17 October
2021, from https://xlinux.nist.gov/dads/HTML/inplacesort.html.

8. Data Structures Tutorials - Heap Sort Algorithm. Btechsmartclass.com. Retrieved 17


October 2021, from http://www.btechsmartclass.com/data_structures/heap-sort.html.

9. Heap Sort Algorithm - InterviewBit. InterviewBit. Retrieved 17 October 2021, from


https://www.interviewbit.com/tutorial/heap-sort-algorithm/.

10. Heap Sort. Programiz.com. Retrieved 17 October 2021, from


https://www.programiz.com/dsa/heap-sort.

11. Merge Sort Algorithm www.javatpoint.com. Retrieved 18 October 2021, from


https://www.javatpoint.com/merge-sort
12. Holamyself (2019) Merge sort, advantages and disadvantages getrevising.co.uk
Retrieved 18 October 2021, from
https://getrevising.co.uk/grids/merge-sort-advantages-and-disadvantages
13. Working on Merge Sort Algorithms www.javatpoint.com Retrieved 18 October 2021,
from https://www.javatpoint.com/merge-sort
14. conrad, keith. (2017). Stirling’s Formula. The Probability Lifesaver, 469–493.
https://doi.org/10.2307/j.ctvc7767n.22
15. Sharma, R. (2020, November 23). Heap sort in data structures: Usability and
performance. upGrad blog. Retrieved October 19, 2021, from
https://www.upgrad.com/blog/heap-sort-in-data-structures/.
16. Merge Sort - GeeksforGeeks. GeeksforGeeks. (2021). Retrieved 19 October 2021,
from https://www.geeksforgeeks.org/merge-sort/.
17. Wandy, J. (2019, March 2). The advantages of heap sort. Sciencing. Retrieved
October 19, 2021, from
https://sciencing.com/the-advantages-of-heap-sort-12749895.html.

You might also like