Computers and Technology
Computers and Technology, 18.09.2019 19:00, aavil5659

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?

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 11:30, stodd9503
Awell-diversified portfolio needs about 20-25 stocks from different categories is this true or false?
Answers: 2
image
Computers and Technology, 22.06.2019 19:30, bstine6678
When creating a presentation in libre office impress, where does the editing of slides take place? a. the slides panel b. the center panel c. the tasks panel, under the masters pages tab d. the tasks panel, under the layouts tab
Answers: 1
image
Computers and Technology, 24.06.2019 14:30, SmartScholar4094
Two students are discussing electricity that has a frequency of 60 hz. student a says that this type of electricity is referred to as ac. student b says that in this type of electricity, the electrons flow in only one direction. which of the following statements is correct? a. only student a is correct b. only student b is correct c. both of the two students are correct d. neither of the two students is correct
Answers: 1
image
Computers and Technology, 24.06.2019 22:30, toricepeda82
What are the 4 basic items that are traded throughout the world?
Answers: 1
Do you know the correct answer?
2. (25 points) consider the following procedure acting on an array a[1: : n]. insertion sort(a[1: :...

Questions in other subjects:

Konu
History, 19.04.2021 04:40