Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

i have this example: 14. Show all the steps for searching the number 60 in the given array using binary search. [6 marks) 0 5

image text in transcribed
i have this example:
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
14. Show all the steps for searching the number 60 in the given array using binary search. [6 marks) 0 5 5 13 19 22 41 55 68 72 81 98 Example 4 (1) Search worst case t = 42 0 2 3 4 5 6 7 2 5 7 11 15 22 28 35 41 64 min=0 mid=4 max = 9 First Iteration mid = ( min + max )/2 = (0+9)/2 =4 compare t with A[mid] As 42 > 15, adjust the min min=mid + 1 = 4+ 1 = 5 Example 4 (2) Search worst case t = 42 0 ! 2 3 + 5 6 7 2 5 7 11 15 22 28 35 41 64 min - 5 mid=7 max 9 o O Second Iteration mid = ( min + max )/2 = (5 +9)/2 = 7 compare t with A[mid] As 42 > 35, adjust the min min = mid + 1 = 7+ 1 = 8 O O 0 Example 4 (3) Search worst case t=42 0 1 2 3 5 7 8 2 5 7 11 15 22 28 35 41 64 min 8 max = 9 mid=8 o Third Iteration mid=( min + max )/2 =(8 + 9)/2 = 8 compare t with Amid) As 42 > 41, adjust the min min=mid + 1 = 8+ 1 = 9 Example 4 (4) Search worst case t=42 0 1 2 3 4 5 6 7 # 2 5 7 11 15 22 28 35 41 64 max = 9 min9 O Fourth Iteration mid= (min + max 1x)/2=(9+9)/2 = 9 mid=8 o 0 compare t with A[mid] As 42

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

Practical Issues In Database Management A Refernce For The Thinking Practitioner

Authors: Fabian Pascal

1st Edition

0201485559, 978-0201485554

Students also viewed these Databases questions

Question

2. Identify and choose outcomes to evaluate a training program.

Answered: 1 week ago

Question

6. Conduct a cost-benefit analysis for a training program.

Answered: 1 week ago