Question: algorthams please solve it with clear hand write 2: 3: 4: 5: 3. Frequency of an Element. (10 points) Let A be an unsorted array

algorthams please solve it with clear hand write algorthams please solve it with clear hand write 2: 3: 4: 5:

2: 3: 4: 5: 3. Frequency of an Element. (10 points) Let A be an unsorted array with n (possibly duplicate) elements. Suppose you want to find the number of occurrences of a given element k. For example, if A = 3,1,1,2,1,1.7.2) and we want to find the number of occurrences of the element k = 1 then the algorithm should return 4. The following pseudocode attempts to solve this problem using a divide-and-conquer technique: 1: procedure FINDFREQ(A,K) if n=1 then Base Case if A[0] = k then Return 1 else Return 0 end if end if n = FINDFREQ(A1,....), k) Recursive call over first third of A 10: 12 = FINDFREQ(A5 +1,...,n), k) Recursive call over the other two-thirds of A Return y+12 12: end procedure (a) (4 points) State the divide, conquer, and combine steps (including the number of sub- problems and each subproblem size). Then write down the recurrence 7(n) for this algorithm (b) (6 points) Solve the recurrence in part (a) using the recursion tree method to get an upper bound (i.c. O-notation) on 7(n). 6: 7: 8: 9: 11

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!