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
in C++... kth Element Extend the class linkedListType by adding the following operations:a. Write a function that returns the info of the kth element of the linked list. If no such element exists, terminate the program.b. Write a function that deletes the kth element of the linked list. If no such element exists, terminate the program. Provide the definitions of these functions in the class linkedListType.   PLEASE DON'T reject this question, this is the whole question that I have... so please do it however u can, Thank you!
Add the following functions and write a program to test these functions in the class linkedListType: a. Write the definition of a function that returns the data of the kth element of the linked list. If such element is not exist in the list, exit the program. b. Write the definition of a function that deletes the kth element of the linked list. If such element is not exist in the list, exit the program and display message as output. (Subject:Data stracture and algorithm )
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.
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