Question: Consider the following algorithm: procedure who knows (a_1,a_2,...a_n: integers) k = 0 for (i 1 to n-1) for(j=i+1 to n). : if la ia_j
Consider the following algorithm: procedure who knows (a_1,a_2,...a_n: integers) k = 0 for (i 1 to n-1) for(j=i+1 to n). : if la ia_j >k then k = |a_i - a_jl a. What does the algorithm compute? b) How many comparisons are made? c) Give the time-complexity in terms of big-O 5 Question-5 Work out with an analysis, a faster algorithm to solve the same problem as solved by Question-4.
Step by Step Solution
There are 3 Steps involved in it
Array Statistics This involves finding the lowest highest average middle and sum of numbers in an ar... View full answer
Get step-by-step solutions from verified subject matter experts
