Fill the array using random


1. Fill the array using random numbers.

srand(time(0));
for (int i = 0; i < length; i++)
list[i] = rand() % 20000;
Now copy this array two times. You need the same exact array, with the same values so you can compare sorts.

2. Execute each sort on each list(array). Example of function calls,
· bubbleSort2(list1, 5000, compBubbleSort, assignBubbleSort);
· selectionSort2(list2, 5000, compSelectionSort, assignSelectionSort);
· insertionSort2(list3, 5000, compInsertionSort, assignInsertionSort);
·
3. Use this output code. You can use different variables.
· 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;

Request for Solution File

Ask an Expert for Answer!!
Data Structure & Algorithms: Fill the array using random
Reference No:- TGS01099858

Expected delivery within 24 Hours