Please answer according to the image attached. No need for explanation! What is the name of the variable that will store the value that you are searching? What is the name of the array that stores the values? What is the data type of found? (True or False) The program makes use of a dynamic array. (True or False) The program will compare the search item to each of the element in the array. (True or False) The worst case scenario in a binary search is when the item you are looking for is not found in the list.  What will be the value of found when a search is successful? What variable represents the output of the output of the function? What is the output if a search is unsuccessful? What is the data type that will be returned by the function?

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

Please answer according to the image attached.

No need for explanation!

  1. What is the name of the variable that will store the value that you are searching?
  2. What is the name of the array that stores the values?
  3. What is the data type of found?
  4. (True or False) The program makes use of a dynamic array.
  5. (True or False) The program will compare the search item to each of the element in the array.
  6. (True or False) The worst case scenario in a binary search is when the item you are looking for is not found in the list.
  7.  What will be the value of found when a search is successful?
  8. What variable represents the output of the output of the function?
  9. What is the output if a search is unsuccessful?
  10. What is the data type that will be returned by the function?
template <class elemType>
int binarySearch (const elemType list[], int length,
const elemType& item)
{
int first = 0;
int last = length - 1;
int mid;
bool found =
false;
while (first <= last && !found)
{
mid =
(first + last) / 2;
if (list[mid]
item)
found = true;
else if (list[mid] > item)
last = mid - 1;
else
first = mid + 1;
}
if (found)
return mid;
else
return -1;
} //end binarySearch
Transcribed Image Text:template <class elemType> int binarySearch (const elemType list[], int length, const elemType& item) { int first = 0; int last = length - 1; int mid; bool found = false; while (first <= last && !found) { mid = (first + last) / 2; if (list[mid] item) found = true; else if (list[mid] > item) last = mid - 1; else first = mid + 1; } if (found) return mid; else return -1; } //end binarySearch
Expert Solution
steps

Step by step

Solved in 2 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