Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The following algorithm, Find01, takes as input a binary string of length n 2 whose bits are b1, b2, . . . , bn that

The following algorithm, Find01, takes as input a binary string of length n 2 whose bits are b1, b2, . . . , bn that starts with 0 and ends with 1. This algorithm returns a position i such that bi = 0 and bi+1 = 1. Find01(b1, b2, . . . , bn : binary string of length n 2 with b1 = 0 and bn = 1)

image text in transcribed

The following algorithm, Find01, takes as input a binary string of length n > 2 whose bits are b1, b2, ...,bn that starts with 0 and ends with 1. This algorithm returns a position i such that b = 0 and bi+1 = 1. Findo1 (b1, b2, ...,bn : binary string of length n > 2 with bi = 0 and bn = 1) 1. if n = 2 then 2. return 1 3. mid := (n/2) 4. if bmid = 0 and bmid+1 =1 then 5. return mid 6. else if bmid = 1 and &mid+1 =1 then 7. return Findo1(b1,...,bmid) 8. else 9. return mid + Findo1(6mid+1,...,bn) (a) (6 points) Prove that Find01 is correct. (b) (1 point) Give an example of a best-case input of size n = 6. Explain why this is a best-case input. (c) (1 point) What is the order of the algorithm in O notation, in the best case? Show how you get to your answer, using any valid method. (d) (1 point) Give an example of a worst-case input of size n = 6. Explain why this is a worst-case input. (e) (1 point) What is the order of the algorithm in O notation, in the worst case? Show how you get to your answer, using any valid method

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

Intelligent Information And Database Systems Asian Conference Aciids 2012 Kaohsiung Taiwan March 19 21 2012 Proceedings Part 3 Lnai 7198

Authors: Jeng-Shyang Pan ,Shyi-Ming Chen ,Ngoc-Thanh Nguyen

2012th Edition

3642284922, 978-3642284922

More Books

Students also viewed these Databases questions