Problem Solving with C++ (10th Edition)
Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134448282
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
Question
Book Icon
Chapter 17, Problem 3P
Program Plan Intro

Recursive Binary Search

Program Plan:

  • Include the required header files.
  • Declare the global variables.
  • Declare the function template.
  • Define main function.
    • Declare the required variables.
    • Get the array of elements.
    • Display the given display.
    • Sort the array in ascending order.
    • Display the sorted array.
    • Call the “search” function with the arguments.
    • If the “found” value is true, display the search element location. Otherwise display, “the element is not found”.
  • Define the “search” function
    • Declare the variable
    • If “first” is greater than “last”, set “found” value as “false”.
    • Otherwise find the “mid” value.
      • If the “key” value is equal to “a [mid]”, set “found” value as “true” and also set “location” as “mid”.
      • If the “key” is less than “a [mid]”, call the “search” function with the arguments.
      • Otherwise, call the “search” function with the arguments.

Blurred answer
Students have asked these similar questions
3. Write a class for the city database using unordered lists. Each database record contains the name of the city (a string of arbitrary length) and the coordinates of the city expressed as integer x and y coordinates. Your database should allow records to be inserted, deleted by name, and searched by name or coordinate. Implement the database using an array-based list. Develop a simple test (as the main function) Run your program and present the results of the test.
WITHOUT USING VECTOR ARRAY. Using c++ . Write different code rather than  2 codes that already existed in this question on this website.
Provide me complete and correct solution thanks 3
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning