subject

Write a program that creates three identical arrays, list1, list2, and list3 of 5000 elements. The program then sorts list1 using bubble sort, list2 using selection sort, and list3 using insertion sort and outputs the number of comparisons and item assignments made by each sorting algorithm. I have 2 separate files, functions. cpp and main. cpp
These were given to me by the assignment, which is from Cengage

functions. cpp

#include
#include
#include

using namespace std;

inline void fillArray(int list[], int length)
{
srand(time(0));

for (int i = 0; i
#include
#include
#include "functions. cpp"

using namespace std;

int main()
{
int list1[5000];
int list2[5000];
int list3[5000];

int compBubbleSort = 0, compSelectionSort = 0, compInsertionSort = 0;
int assignBubbleSort = 0, assignSelectionSort = 0, assignInsertionSort = 0;

fillArray(list1, 5000);
copyArray(list1, list2, 5000);
copyArray(list1, list3, 5000);

bubbleSort(list1, 5000, compBubbleSort, assignBubbleSort);
selectionSort(list2, 5000, compSelectionSort, assignSelectionSort);
insertionSort(list3, 5000, compInsertionSort, assignInsertionSort);

cout << "Number of comparisons---" << endl;
cout << " Bubble sort: " << compBubbleSort << endl;
cout << " Selection sort: " << compSelectionSort << endl;
cout << " Insertion sort: " << compInsertionSort << endl << endl;

cout << "Number of item assignments---" << endl;
cout << " Bubble sort: " << assignBubbleSort << endl;
cout << " Selection sort: " << assignSelectionSort << endl;
cout << " Insertion sort: " << assignInsertionSort << endl << endl;

return 0;
}


They expected me to learn everything in 30 days, and the readings were over 30 pages, which would constantly glitch out or have so many spelling/grammatical errors I couldn't understand nor process them. It's overdue now, and I desperately need help. I still don't understand any of the lessons. Help would be extremely appreciated.

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 15:30, sammuelanderson1539
Which function in spreadsheet software can be used to predict future sales or inventory needs?
Answers: 2
image
Computers and Technology, 22.06.2019 10:40, StephiUnicorni
When running anti-virus software , what could be a reason where recipitent is not guaranteed that data being streamed will not get interrupted?
Answers: 1
image
Computers and Technology, 23.06.2019 00:30, hannahrasco4051
Pl i need the answer now ! which one of the following is considered a peripheral? a software b mouse c usb connector d motherboard
Answers: 1
image
Computers and Technology, 23.06.2019 14:30, ladawnrowles005
The option enables you to modify a slide element in most presentation applications.
Answers: 2
You know the right answer?
Write a program that creates three identical arrays, list1, list2, and list3 of 5000 elements. The p...

Questions in other subjects:

Konu
Chemistry, 19.03.2021 01:00
Konu
Mathematics, 19.03.2021 01:00