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

Data Structures and Algorithms in C++
Homework Solution
$35.00
Computer Science
Data Structures
Algorithms
C++ Programming
Countries
Pointers
Quick Sort
Bubble Sort
Functions
Linear Search
Data
Keys
Shuffling
Programming Problems in C++
Homework Solution
$10.00
Programming
Computer Science
C++
Classes
Libraries
Command Line Arguments
Music Files
Statements
Variables
Scripts
Input
Output
Information
Underscores
Spaces
Track Numbers
Lexicographic Sorting
Songs
Data Structures Problems
Homework Solution
$83.00
Computer Science
Data Structures
Big Data
Insert Functions
Operations
Sorting
Arrays
Lists
Storage
Nodes
References
Methods
Binary Trees
Memory Cells
Illustration
Comparison
Greedy Strategy Programming Problem
Homework Solution
$10.00
Computer Science
Programming
Greedy Strategy
Algorithms
Company
Workers
Properties
Sets
Shifts
Intervals
Variables
Statements
Sequences
Complexity
Finish Time
Input
Output
Array Problems
Homework Solution
$20.00
Computer Science
Programming
Arrays
Pseudocode
Algorithms
Numbers
Products
Efficient Solutions
Loops
Running-Time
Get help from a qualified tutor
Live Chats