Starting Out With C++: Early Objects (10th Edition)
10th Edition
ISBN: 9780135235003
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
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.
- Define and create a random array having 10 elements.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Complete using Standard C programming. Implement a singly linked list that performs the following: Displays the maximum value in the linked list using recursion. Displays the linked list in reverse order using recursion. Merge two single linked lists and display.
Show a complete run of Quicksort on the following array X :X: 1 2 3 4 5 6 7 8 9 1017 5 -3 40 46 50 16 0 22 4
show all recursive calls using the stack below. Show the results of each call to below Split on a newline in the table to the left.
Write 2 recursive functions
1. to count number of even values in an
array
2. to count number of even values in a
simply linked list
Chapter 18 Solutions
Starting Out With C++: Early Objects (10th Edition)
Ch. 18.3 - Describe what LIFO means.Ch. 18.3 - What is the difference between static and dynamic...Ch. 18.3 - What are the two primary stack operations?...Ch. 18.3 - What STL types does the STL stack container adapt?Ch. 18 - Prob. 1RQECh. 18 - Prob. 2RQECh. 18 - What is the difference between a static stack and...Ch. 18 - Prob. 4RQECh. 18 - The STL stack is considered a container adapter....Ch. 18 - What types may the STL stack be based on? By...
Ch. 18 - Prob. 7RQECh. 18 - Prob. 8RQECh. 18 - Prob. 9RQECh. 18 - Prob. 10RQECh. 18 - Prob. 11RQECh. 18 - Prob. 12RQECh. 18 - Prob. 13RQECh. 18 - Prob. 14RQECh. 18 - Prob. 15RQECh. 18 - Prob. 16RQECh. 18 - Prob. 17RQECh. 18 - Prob. 18RQECh. 18 - Prob. 1PCCh. 18 - Prob. 2PCCh. 18 - Prob. 3PCCh. 18 - Prob. 4PCCh. 18 - Prob. 5PCCh. 18 - Prob. 6PCCh. 18 - Prob. 7PCCh. 18 - Prob. 8PCCh. 18 - Prob. 14PCCh. 18 - Prob. 9PCCh. 18 - Prob. 10PCCh. 18 - Prob. 11PCCh. 18 - Prob. 12PCCh. 18 - Prob. 13PCCh. 18 - Prob. 15PC
Knowledge Booster
Similar questions
- python: Describe a fast recursive algorithm for reversing a singly linked list.arrow_forwardStack: push(x) adds x to top of stack pop() removes top element of stack and returns it size() returns number of elements in stack Select all options that allow for an efficient implementation based on the discussions from class. For any array implementation, you can assume the array is large enough so that making a larger one is not needed when pushing an item to the stack. Using an array with the top at the front of the array. Using an array with the top at the back of the array. Using a singly linked list with the top at the head of the list. Using a singly linked list with the top at the tail of the list. None of these choices allows for an efficient implementation of all methods.arrow_forwardA tail recursion is a type of recursion in which the access of the tail pointer of a linked list is recursive a) true b)falsearrow_forward
- What happens if the base condition is not defined in recursion ? a. Stack underflow b. Stack Overflow c. None of these d. Both a and barrow_forwardRecursion and list processing Write a maxel that returns the maximum element in an arbitrarily complex list (e.g., list that may contain lists, which may contain lists, and so on). For example, (maxel '(((5)) (9 (3)) 7)-> 9arrow_forwardHaskarrow_forward
- javaarrow_forwardProb 1 Given a list of x objects, create a program that performs the following operation: -Get the first and last object and place them both at the end of the list. Example: QWERT becomes WERQT Find the worst case time complexity if the solution will be implemented using a stack. Give both the EQUATION AND THE BIG-O NOTATION.arrow_forwardModule 5: Merge Sort Merge Sort works by continuously partitioning a list into two smaller sub-lists so it is working with smaller sub-lists during each recursive call. When does the Merge Sort method stop partitioning a list into sub-lists and begin returning? After four divides When each sublist has one element When each sublist is already sorted When each sublist has two elementsarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning