31.8k views
1 vote
. Create an array with all the numbers from 1 to 100 (each number should appear exactly once). 2. Write a function to shuffle the list so each number is in a random unknown position. 3. Modify the selection sort and quick sort functions to return the number of comparisons performed. 4. Repeat the following process 100 times: 1. Shuffle the list. 2. Use selection sort and quick sort to sort the same shuffled list (may need two copies of it). 1. Keep track of the number of comparisons performed using each algorithm. 5. Display the average number of comparisons performed to sort the shuffled lists using each of the sorting algorithms. 6. Create an array with all the numbers from 1 to 1000 . Shuffle the array. Then, use both the sequential and binary search algorithms to search each of the numbers from 1 to 1000. 1. Modify binary search and sequential search to return the number of comparisons performed instead of (or in addition to) an index.

∗∗
You may pass a parameter by reference to count comparisons instead of returning. 7. Print the average number of comparisons performed to find the numbers using binary search and using sequential search.

1 Answer

7 votes

Final answer:

This question is about programming and data manipulation involving arrays, sorting algorithms, and search algorithms.

Step-by-step explanation:

This question is related to programming and data manipulation. It involves creating, shuffling, and sorting arrays, as well as implementing search algorithms and tracking the number of comparisons performed. The question also mentions the use of functions and loops to repeat the process multiple times.

This question requires knowledge of programming concepts and algorithms.

User Erik Forsberg
by
8.8k points