Invitation to Computer Science 8th Edition

Published by Cengage Learning
ISBN 10: 1337561916
ISBN 13: 978-1-33756-191-4

Chapter 3 - Exercises - Page 145: 26

Answer

Perform a binary search on the list:$[3,6,7,9,12,14,18,21,22,31,43]$ Search for $35 .$ $\bullet$ begin $=3 ;$ end $=43 ; m=14$ $\ \ \ $Compare 14 to 35.35 follows 14 $\ \ \ $Set begin to $m+1=18$ $\bullet$ begin $=18 ;$ end $=43 ; m=22$ $\ \ \ $Compare 22 to 35.35 follows 22 $\ \ \ $Set begin to $m+1=31$ $\bullet$ begin $=31 ;$ end $=43 ; m=31$ $\ \ \ $Compare 31 to 35.35 follows 31. $\ \ \ $Set begin to $m+1=43$ ; $\ \ \ $since begin $=$ end set Found $=$No and stop the Algorithm.

Work Step by Step

--
Update this answer!

You can help us out by revising, improving and updating this answer.

Update this answer

After you claim an answer you’ll have 24 hours to send in a draft. An editor will review the submission and either publish your submission or provide feedback.