Problem Solving with C++ (9th Edition)
Problem Solving with C++ (9th Edition)
9th Edition
ISBN: 9780133591743
Author: Walter Savitch
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
Write a template version of the iterative binary search algorithm from Display 13.8 which only searches an array of integers for an integer key. Specify requirements on the template parameter type. Discuss the requirements on the template parameter type.
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 )
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education