Question

Question 1. Below is the pseudo code for a divide and conquer algorithm that finds the minimum value in an array. Suppose tha
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Solution:

Let n = is the size of items in an array

Let T (n) = time required to apply the algorithm on an array of size n. Here we divide the terms as T(n/2).

1 here tends to the comparison of the minimum with minimum as in above given algorithm.

Thus, T(n) can be written as

T(n) = T(n/2) + T(n/2) + 1

or

T(n) = 2T(n/2) + 1

We can solve this using master's method as below:

a = 2, b = 2, f(n) = 1, c = 0 as n0 = 1, logba = log22 = 1

We observe that c < logba; case 1 applies. So Solution would be:

T(n) = theeta(nlogba) = theeta(n1) = theeta(n).

Please give thumbsup, if you like it. Thanks.

Add a comment
Know the answer?
Add Answer to:
Question 1. Below is the pseudo code for a divide and conquer algorithm that finds the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT