(a) Design an algorithm that reveals some secret integer number from the set {1, 2, ......

90.2K

Verified Solution

Question

Advance Math

(a) Design an algorithm that reveals some secret integer numberfrom the set {1, 2, ... , n} by guessing random numbers within thegiven range until the secret number has been guessed. Numbersshould be replaced after being guessed such that ?it is possible toguess 2 and then 2 again?, assuming 2 is in the given range. Thealgorithm should return both the secret number as well as thenumber of guesses taken.

(b) If possible, calculate the tightest Big-?O? approximationfor the average runtime complexity of the algorithm from part (a).If it is not possible, explain why not. Note: assume that choosinga random number takes ?O(1)? time.

(c) If possible, calculate the tightest Big-?O? approximationfor the worst case runtime complexity of the algorithm from part(a). If it is not possible, explain why not. Note: assume thatchoosing a random number takes ?O(1)? time.

(d) In a single run, is it possible that of the algorithm frompart (a) finds the secret number in fewer guesses than a standardbinary search algorithm? If so, please provide a concrete exampleof one such situation.

Answer & Explanation Solved by verified expert
3.6 Ratings (299 Votes)
IF YOU HAVE ANY DOUBTS COMMENT BELOW I WILL BETTHERE TO HELP YOUALL THE BESTANSWERcode and explanation1assuming set    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students