Write a program to test the performance of insertion Vs selection sort. Also, show the output after execution. The Output will be varying for
Write a program to test the performance of insertion Vs selection sort. Also, show the output after execution. The Output will be varying for each student. (Hint: you can use System nanoTime() to measure the time is taken to perform the insertion sort and selection sort on random numbers) Sample Output: For Size = 100 Time taken to sort using Insertion sort: 141847 nanoseconds Time taken to sort using selection sort: 205994 nanoseconds For Size 1000 Time taken to sort using Insertion sort: 5250599 nanoseconds Time taken to sort using selection sort: 8478750 nanoseconds For Size 10000 Time taken to sort using Insertion sort: 83530293 nanoseconds Time taken to sort using selection sort: 102450611 nanoseconds For Size = 100000 Time taken to sort using Insertion sort : 5645860325 nanoseconds Time taken to sort using selection sort: 6261418687 nanoseconds
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Heres a Java program to test the performance of insertion sort vs selection sort on random numbers a...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