Consider using the Binary Search Algorithm, shown above, to find if 75 belongs to the following list: 4 8. 19 25 34 39 45 48 66 75 89 95 How many iterations are needed until we find 75 in this list? OI. Five iterations are needed OI. All the answers are wrong O I. Four iterations are needed O IV. Three iterations are needed OUESTION 2

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

How many iterations are needed untill we find 75 in this list

 

Consider using the Binary Search Algorithm, shown above, to find if 75 belongs
to the following list:
8
19
25
34
39
45
48
66
75
89
95
How many iterations are needed until we find 75 in this list?
OI.
Five iterations are needed
O I.
All the answers are wrong
O II.
Four iterations are needed
O V.
Three iterations are needed
OUESTION 2
Transcribed Image Text:Consider using the Binary Search Algorithm, shown above, to find if 75 belongs to the following list: 8 19 25 34 39 45 48 66 75 89 95 How many iterations are needed until we find 75 in this list? OI. Five iterations are needed O I. All the answers are wrong O II. Four iterations are needed O V. Three iterations are needed OUESTION 2
int binarySearch (const int list[], int listlength, int searchItem)
int first - 0;
int last - listLength - 1;
int mid;
bool found = false;
while (first <= last && !found)
mid = (first + last) / 2;
if (list[mid] == searchItem)
found - true;
else if (1ist(mid] > searchItem)
last mid - 1;
else
first - mid + 1;
if (found)
return mid;
else
return -1;
}//end binarySearch
Consider using the Binary Search Algorithm, shown above, to find if 75 belongs
to the following list:
Windows buAL
Transcribed Image Text:int binarySearch (const int list[], int listlength, int searchItem) int first - 0; int last - listLength - 1; int mid; bool found = false; while (first <= last && !found) mid = (first + last) / 2; if (list[mid] == searchItem) found - true; else if (1ist(mid] > searchItem) last mid - 1; else first - mid + 1; if (found) return mid; else return -1; }//end binarySearch Consider using the Binary Search Algorithm, shown above, to find if 75 belongs to the following list: Windows buAL
Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY