Question

(2) Consider the following algorithm for the problem: for i = 1 to n do a binary search for -X[i] in Y[1 if found n] return true; return false; (a) (5 pts) What is the complexity of this algorithm? Briefly justify.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

In the given snippet, there is a main for loop. For each iteration is is searching for some value in the array. Time complexity of binary search is log(N) and the same binary search is being performed n times. So, total complexity is O(NlogN)

Add a comment
Know the answer?
Add Answer to:
(2) Consider the following algorithm for the problem: for i = 1 to n do a...
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