Starting Out with C++: Early Objects (9th Edition)
Starting Out with C++: Early Objects (9th Edition)
9th Edition
ISBN: 9780134400242
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: PEARSON
Question
Book Icon
Chapter 18, Problem 12PC
Program Plan Intro

Stack Based Binary Search

Program Plan:

  • Create a class Range.
    • Include required header files.
    • Declare two integers lower and upper to set the lower and upper level for comparison.
    • Set the range for comparison.
    • Create a method binary search that searches for an element within two levels where the element array, size of array and the number to search is passed as a parameter.
  • Create the main function.
    • Define and create a random array having 10 elements.
      • Define the array size.
      • Prompt the user to ask for a value to search within array.
      • Call the binary search method and return the position of the value if it is present in the array.

Blurred answer
Students have asked these similar questions
Rewrite the procedure DFS (depth first search), using a stack to eliminate recursion.
Write a recursive program to insert an element in the sorted array using stack in pyhton
Python: Describe a recursive algorithm that counts the number of nodes in a singly linked list.
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