subject

2. (25 points) consider the following procedure acting on an array a[1: : n]. insertion sort(a[1: : n]) cost times 1. for j 2 to n c1 2. key a[ j] c2 3. i c3 4. while i > 0 and a[i] > key c4 5. a[i+1] a[i] c5 6. i c6 7. a[i+1] key c7 (a) let t j denote the number of times the while loop test in line 4 is executed for that value of j. fill in for each line of instruction, the number of times the instruction is executed. (b) derive the expression for the running time of insertion sort in terms of n, ci, and t j. (c) what is t j for the best-case scenario, i. e., when the running time of the algorithm is the smallest. use that to derive the expression for the best-case running time of insertion sort in terms of n and ci. what is the best-case time complexity of insertion sort using the big-o notation? (d) what is t j for the worst-case scenario, i. e., when the running time of the algorithm is the largest. use that to derive the expression for the worst-case running time of insertion sort in terms of n and ci. what is the worst-case time complexity of insertion sort using the big-o notation?

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 22:30
What is the most popular genre of video games?
Answers: 1
question
Computers and Technology, 23.06.2019 04:10
2pointswho was mikhail gorbachev? oa. a russian leader who opposed a coupob. a polish leader who founded the labor union "solidarityoc. a soviet leader who called for a closer relationship with the unitedstates, economic reform, and a more open societyd. a soviet leader who called for more oppression in the soviet union
Answers: 3
question
Computers and Technology, 23.06.2019 04:31
This graph compares the cost of room and board at educational institutions in texas.
Answers: 1
question
Computers and Technology, 24.06.2019 11:30
Why is body language an important factor in a business meeting
Answers: 1
You know the right answer?
2. (25 points) consider the following procedure acting on an array a[1: : n]. insertion sort(a[1: :...
Questions
Questions on the website: 13722363