Starting from an empty project using C, you must:1.Create two arrays of length 20,000 and insert the same random number into each index (i.e. thetwo arrays should be separate arrays but contain...

1 answer below »


Starting from an empty project using C, you must:1.Create two arrays of length 20,000 and insert the same random number into each index (i.e. thetwo arrays should be separate arrays but contain identical values).2.Sort the first array using a bubble sort. Print the length of time it took to perform the sort.3.Sort the second array using a heap sort. Print the length of time it took to perform the heap sort.For the timing, you can use the following algorithm (or any timing code you wish):#include ...clock_t startTime = clock();//Sort happens hereclock_t endTime = clock();double sortTime = (double)(endTime - startTime) / CLOCKS_PER_SEC;4.Print the time it took to perform each sort.5.Insert a break point at the end of your code and during the presentation show the contents ofthe two arrays after they have been sorted using the debugger.Note:This assignment depends on the speed of your computer. If you find 20,000 is taking too long, youmay shorten it. If it happens too quickly and you don't see a difference, you may increase the length.
Answered Same DayApr 25, 2021

Answer To: Starting from an empty project using C, you must:1.Create two arrays of length 20,000 and insert the...

Vaishnavi R answered on Apr 25 2021
154 Votes
New folder (5)/afterBS.png
New folder (5)/afterHS.png
New folder (5)/beforeBS.png
New folder (5)/
beforeHS.png
New folder (5)/correctopTime.png
New folder (5)/Untitled2.cpp
#include
#include
#include
void bubbleSort(int a[], int len)
{
int i, j;
for (i = 0; i < len-1; i++)
for (j = 0; j < len-i-1; j++)
{
if (a[j] > a[j+1])
{
int t;
t = a[j];
a[j] = a[j+1];
a[j+1]=t;
}
}
}
void Heapify(int a[], int len, int k)
{
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here