Question

Implement 3 sorting algorithms;
(1)   Selection Sort (O(N²))
(2)   Heap Sort (O(NlogN))
(3)   Counting Sort

Record the execution time for every sorting algorithm in each input dataset. You also need to prepare one page report to explain the execution time comparison (use a figure) on all implemented algorithms.

Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
#include <ctime>

using namespace std;



void max_heapify(int *a, int i, int n)
{
int j, temp;
temp = a[i];
j = 2 * i;
while (j <= n)
{
if (j < n && a[j + 1] > a[j])
j = j + 1;
if (temp > a[j])
break;
else if (temp <= a[j])
{
a[j / 2] = a[j];
j = 2 * j;
}
}
a[j / 2] = temp;

}
void heapsort(int *a, int n)
{
int i, temp;
for (i = n; i >= 2; i--)
{
temp = a[i];
a[i] = a[1];
a[1] = temp;
max_heapify(a, 1, i - 1);
}
}...

This is only a preview of the solution. Please use the purchase button to see the entire solution

Related Homework Solutions

Algorithm Design, Desk Check & Checking Table
Homework Solution
$25.00
Algorithm
Design
Desk
Check
Checking
Table
Gender
Married
Age
Marital
Status
Student
Single
Men
Women
Student
Name
Bachelor
Report
Input
Data
Expected
Results
Algorithms Assignment
Homework Solution
$1.00
Algorithm
Computer Science
Graphs
Programming Language
Programming
Analysis
Big Data (530 words)
Homework Solution
$20.00
Big
Data
Algorithm
Input
Output
Complexity
Technical
Scientific
Theory
Performance
Criteria
Cost
Euclidean
Machine
Learning
Structured
Unstructured
Analytics
Business
Voronoi
NP-Hard
Partition
Clustering
Mean
Dynamic Programming Model for A Version of Job Scheduling Problem
Homework Solution
$30.00
Knapsack
Reduction
Algorithm
Complexity
Problem
Job
Scheduling
Dynamic
Programming
OPT
Optimal
Swapping
Exchange
Argument
Playful
Subset
Deadline
Value
Size
Profit
Function
Solution
Set
Array
Two
Dimensional
Selection
Reorder
M
Get help from a qualified tutor
Live Chats