Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Case Studies In Business Data Bases

Authors: James Bradley

1st Edition

0030141346, 978-0030141348

More Books

Students also viewed these Databases questions

Question

What is Accounting?

Answered: 1 week ago

Question

Define organisation chart

Answered: 1 week ago

Question

What are the advantages of planning ?

Answered: 1 week ago