 Sorting Algorithms in C++

Subject Computer Science Data Structures and Algorithms

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;
a = 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 \$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 \$1.00
Algorithm
Computer Science
Graphs
Programming Language
Programming
Analysis
Function Asymptotic Growth & Basic Java Programming Questions \$15.00
Asymptotic
Growth Rate
Java
Main
Maryland
State
Method
Output
Class
Extends
Computer Science
Data Structures
Algorithms
Big Data (530 words) \$20.00
Big
Data
Algorithm
Input
Output
Complexity
Technical
Scientific
Theory
Performance
Criteria
Cost
Euclidean
Machine
Learning
Structured
Unstructured
Analytics
Voronoi
NP-Hard
Partition
Clustering
Mean
Dynamic Programming Model for A Version of Job Scheduling Problem \$30.00
Knapsack
Reduction
Algorithm
Complexity
Problem
Job
Scheduling
Dynamic
Programming
OPT
Optimal
Swapping
Exchange
Argument
Playful
Subset
Value
Size
Profit
Function
Solution
Set
Array
Two
Dimensional
Selection
Reorder
M
Algorithm Design about Linear Time Median, BFS with Loop Invariant, and Sorting Post Order Numbers \$20.00
Linear
Time
Median
Find
Algorithm
Group
Element
List
Post
Order
Traversal
Without
Sorting
BFS
First
Search
Loop
Invariant
Layer
Graph
Proof
Complexity
Left
Right
Root
Node
Sorted
Live Chats