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 02:30
The can be used to paste text in any order
Answers: 1
question
Computers and Technology, 23.06.2019 19:30
Amitha writes up a one-page summary of a novel during her summer internship at a publishing company. when she reads over the page, she realizes she used the word “foreshadow” seven times, and she would like to reduce the repetition. which tool would best amitha solve this problem?
Answers: 3
question
Computers and Technology, 24.06.2019 05:30
If you combine two cells into one, what action are you performing? a.  adding a new row or column      b.  splitting the cells      c.  removing a new row or column      d.  merging the cells
Answers: 2
question
Computers and Technology, 24.06.2019 17:30
Looking at the electroscope, describe how you can cause the two leaves at the bottom to repel each other and stay that way
Answers: 3
You know the right answer?
2. (25 points) consider the following procedure acting on an array a[1: : n]. insertion sort(a[1: :...
Questions
question
History, 05.01.2021 06:30
question
Mathematics, 05.01.2021 06:30
question
Mathematics, 05.01.2021 06:30
Questions on the website: 13722359