Question
Write a C++ program to create 2 identical arrays, list1, and list2 each list of 5000 elements. The program then sorts list1 using bubble sort,
Write a C++ program to create 2 identical arrays, list1, and list2 each list of 5000 elements. The program then sorts list1 using bubble sort, list2 using selection sort and outputs the number of comparisons and item assignments made by each sorting algorithm.
Hint: You need to create a random array and then copy it to end up with two identical lists (List1, List2). These two lists must be identical. You will need to sort List1 using bubble sort, and sort the second list List2 using the selection sort algorithm. Finally, you will need to output the number of comparisons and item assignments made by each sorting algorithm. Plea se note that the array should be randomly generated and you can do that by using the random function: rand() from the library.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started