Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134448282
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 17, Problem 2P
Program Plan Intro
Template version of the iterative binary search
Program Plan:
- Include the required libraries
- Define a constant variable
- Define a template for iterative search method
- Define main method
- Declare the required variables
- Get the number that is to be located from user
- Search the element using the if condition
- Print the result
- Define a template for iterative search method
- Declare the required variables
- If the element is not present in the array
- Find out the middle element in the array
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents 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!
Write a program that declares/intializes two arrays as described in main() and has two functions.
main() - The size of both arrays is 5. The first array has elements of type double. The values are for distance measurements. Choose a descriptive name for this array.The second array will have the unit of measure. Choose a descriptive name for this array. Initialize the first 4 elements using an initialization list with the values "mi", "mi", "km", "km".
Assign a new value to the first element of the second array: "km"Assign a value to the last element of the second array: "mi"
Use a loop with statement that ask the user to type in all of the values for the temperatures and assign them to the first array.
Function calls in main() -- you might want to write the definitions first (or at least read about them) before coming back to main() to write the calls. call the function that prints the measurements along with the unit of measure.Call the function that can count the number of…
Write a template-based class that implements a set of items. A set is a collection of items in which no item occurs more than once. Internally, you may represent the set using the data structure of your choice (for example, list, vector, arrays, etc.). However, the class should externally support the following functions: a. Add a new item to the set. If the item is already in the set then nothing happens. b. Remove an item from the set. c. Return the number of items in the set. d. Determine if an item is a member of the set. e. Return a pointer to a dynamically created array containing each item in the set. The caller of this function is responsible for deallocating the memory. Test your class by creating different sets of different data types (for example, strings, integers, or other classes). If you add objects to your set, then you may need to overload the == and != operators for the object’s class so your template-based set class can properly determine membership.
Chapter 17 Solutions
Problem Solving with C++ (10th Edition)
Ch. 17.1 - Write a function template named maximum. The...Ch. 17.1 - Prob. 2STECh. 17.1 - Define or characterize the template facility for...Ch. 17.1 - Prob. 4STECh. 17.1 - Display 7.10 shows a function called search, which...Ch. 17.1 - Prob. 6STECh. 17.2 - Give the definition for the member function...Ch. 17.2 - Give the definition for the constructor with zero...Ch. 17.2 - Give the definition of a template class called...Ch. 17.2 - Is the following true or false? Friends are used...
Ch. 17 - Write a function template for a function that has...Ch. 17 - Prob. 2PCh. 17 - Prob. 3PCh. 17 - Redo Programming Project 3 in Chapter 7, but this...Ch. 17 - Display 17.3 gives a template function for sorting...Ch. 17 - (This project requires that you know what a stack...Ch. 17 - Prob. 6PPCh. 17 - Prob. 7PPCh. 17 - This project requires that you complete...
Knowledge Booster
Similar questions
- Task 4. Utility classes Implement a Menu-Driven program of ArrayList class using the above scenario and perform the following operations. a. Create an object of ArrayList class based on the scenario with explanations of the method used. b. Create a method that will allow inserting an element to ArrayList Class based on the scenario. The input field must be validated as necessary. C. Create a method to delete specific elements in the ArrayList with explanations of the method used.arrow_forwardin C++ kth ElementExtend 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, do not copy from any other sources, give me a fresh new code. Thank youarrow_forwardAdd 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 )arrow_forward
- Write a template for a function called countItemFrequency that accepts as parameters a vector and a value which may be contained in the vector. Iterate through the vector and count the number of occurrences of the value in the vector and return the count to the user. Test your function with int and char types and then with a custom class with the == operator overloaded.arrow_forward3. 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.arrow_forward//Need help fixing some issues with a project. PLEASE read below Write a Java program that implements both Linear Search and Binary Search. The program will take a collection of objects (generic type data) as input and print the number of comparisons needed to find a target element within that collection. You will create the following two Java classes:1. SearchCombo.java : Code for both linearSearch and binarySearch will be in this class. You may take help from the textbook Chapter 9, Section 9.1. However, note that the design requirements are different from the textbook code.•Both search methods must use the Comparable<T> interface and the compareTo() method.•Your program must be able to handle different data types, i.e., use generics.•For binarySearch, if you decide to use a midpoint computation formula that is different from the textbook, explain that formula briefly as a comment within your code. 2. Tester.java : This class will contain the main() method. The user will be…arrow_forward
- You are tasked to implement an abstract data type class which takes in a given input file called input.txt, and processes, identifies and sorts all unique word instances found in the file. Sample Input Hi hello hi good bye goodbye Bye bye good say Sample Output Bye Hi bye hello hi say The input.txt file is found along with the zip folder where this instructions file also came along with. Note: you are not allowed to use pythonic lists, and its methods and functions, and string methods. However the use of the file handling methods (read readlines and readline) are allowed for this project.arrow_forwardWrite a template function that takes as parameter a vector of a generic type and reverses the order of elements in the vector, and then add the function to the program you wrote for Programming Challenge 5. Modify the driver program to test the new function by reversing and outputting vectors whose element types are char, int, double, and string.arrow_forwardmergeAndRemove(int[], int[]) This is a public static function that takes a int[] and int[] for the parameters and returns an int[]. Given two arrays of integers. Your job is to combine them into a single array and remove any duplicates, finally return the merged array.arrow_forward
- Create a template class for a Matrix(2d array) and write the following functions in it. 1. Print the left diagonal 2. Print the right diagonal 3. Print specified row 4. Print specified column 5. Print overall matrix.arrow_forwardUsing JavaScriptDefine a function getMonth which accepts number from 1 to 12 as an argument and return the descriptive name of the month. For example: getMonth(1) should return January while getMonth(12) returns December, finally getMonth(-1) returns null. Use array or object to define a list of names for the month and refrain from using if statement to check the argument if it's 1, 2, etc.arrow_forwardPlease help me with the assignment below The assignment: Make a telephone lookup program. Read a data set of 1,000 names and telephone numbers from a file that contains the numbers in random order. Handle lookups by name and also reverse lookups by phone number. Use a binary search for both lookups. This assignment needs a resource class and a driver class. The resource class and the driver class will be in two separate files. The driver class needs to have only 5 or 7 lines of code. The code needs to be written in Java. Please help me with exactly what I asked for help.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education