5-2. (14 pts) For the following algorithm, specify the number of times each line is executed for each of the best case a

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

5-2. (14 pts) For the following algorithm, specify the number of times each line is executed for each of the best case a

Post by answerhappygod »

5 2 14 Pts For The Following Algorithm Specify The Number Of Times Each Line Is Executed For Each Of The Best Case A 1
5 2 14 Pts For The Following Algorithm Specify The Number Of Times Each Line Is Executed For Each Of The Best Case A 1 (235.98 KiB) Viewed 36 times
5-2. (14 pts) For the following algorithm, specify the number of times each line is executed for each of the best case and worse case, using n = length[A] by filling the following table (Specify only for the lines 1,2,3,4, and 5) in their closed form with all coefficient and constant values specified. Then express each of the best case and worst case running time T(n) using © by specifying the fastest growing term using n= length[A]. The index of the array A starts with 1. You can assume that the array has at least 5 numbers. FUNCTION1 (A, x) // A is an array of integers and x is an integer 4) inlogn 71 1) int y = 5; n 1 2) for (i=3; i <= n2 + 4; i++) { nti 3) if (A[1]>x) { n for (j = 1; j<=i+2; j++){ 5) y=y+j; nlogn 6) } } } n Best Case: T(n) = ( Worst Case: T(n) = @(_nlogo constant Best case Worst case C1 I C2 nt nt) C3 n C4 И O nlognt! C5 0 nlogn
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply