Question: use C++ 1. The following algorithm Histogram1(A,B,N) computes a histogram from integer array A and stores it in array B. both of length N. When

use C++

use C++ 1. The following algorithm Histogram1(A,B,N) computes a histogram from integer

1. The following algorithm Histogram1(A,B,N) computes a histogram from integer array A and stores it in array B. both of length N. When completed. B[k] contains the number of k's that appear in A. Histograml(A, B,N) 1 for k = 1 to N 2 B[k] = 0 3 for i = 1 to N 4 if A[i] == k 5 then B[k] = B[k] + 1 = a. Assuming each line of the code has a cost of 1. show the number of times each line of code is executed, compute an exact expression T(N) for the running time of the algorithm, and give an asymptotically tight bound for T(N). b. Describe the conditions on the inputs for the best-case and worst-case running time for the Histograml algorithm

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!