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
Textbook Question
Chapter 9, Problem 7PC
Binary String Search
Modify the binarySearch function presented in this chapter so it searches an array of strings instead of an array of ints. Test the function with a driver
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
onsider an input string TAM of letters ‘A’, ‘M’, and ‘T’. This string, which is given by the user, ends with ‘#’. It should be stored in a table (or array), called TAMUK. The number of each of these letters is unknown. We have a function, called SWAP(TAM,i,j), which places the ith letter in the jth entry of string TAM and the jth letter in the ith entry of TAM. Note that SWAP(TAM,i,j) is defined for all integers i and j between 0 and length(TAM)–1, where length(TAM) is the number of letters of TAM.
1. Using our algorithmic language, write an algorithm, called Sort_TAM, which sorts the letters in the array TAMUK in a way that all T’s appear first, followed by all A’s, and followed by all M’s. The algorithm Sort_TAM should have one parameter: The array TAMUK. Also, your solution is correct only if the following four constraints are satisfied:
- Constraint 1: Each letter (‘A’, ‘M’, or ‘T’) is evaluated only once.
- Constraint 2: The function SWAP(TAM,i,j) is used only when it is…
Help now please
Python
Finding the common members of two dynamic arrays: Write a program that first reads two arrays and then finds their common members (intersection). The program should first read an integer for the size of the array and then should create the two arrays dynamically (using new) and should read the numbers into array1 and array2 and then should find the common members and show it.
Note: The list of the common members should be unique. That is no member should be listed more than once.
Tip: A simple for loop is needed on one of the arrays (like array1) and one inner for loop for on array2. Then for each member of array1, if we find any matching member in array2, we record it.
Sample run:
Enter the number of elements of array 1: 7
Enter the elements of array 1: 10 12 13 10 14 15 12
Enter the number of elements of array 2: 5
Enter the elements of array 2: 17 12 10 19 12
The common members of array1 and array2 are: 12 10
Chapter 9 Solutions
Starting Out With C++: Early Objects (10th Edition)
Ch. 9.2 - Prob. 9.1CPCh. 9.2 - Prob. 9.2CPCh. 9.2 - Prob. 9.3CPCh. 9.2 - Prob. 9.4CPCh. 9.3 - True or false: Any sort can be modified to sort in...Ch. 9.3 - Prob. 9.6CPCh. 9.3 - Prob. 9.7CPCh. 9.3 - Prob. 9.8CPCh. 9.3 - Prob. 9.9CPCh. 9.6 - Prob. 9.10CP
Ch. 9.6 - Prob. 9.11CPCh. 9.6 - Prob. 9.12CPCh. 9.6 - Prob. 9.13CPCh. 9.6 - Prob. 9.14CPCh. 9.6 - Prob. 9.15CPCh. 9 - Prob. 1RQECh. 9 - Prob. 2RQECh. 9 - Prob. 3RQECh. 9 - Prob. 4RQECh. 9 - Prob. 5RQECh. 9 - Prob. 6RQECh. 9 - Prob. 7RQECh. 9 - A binary search will find the value it is looking...Ch. 9 - The maximum number of comparisons that a binary...Ch. 9 - Prob. 11RQECh. 9 - Prob. 12RQECh. 9 - Bubble sort places ______ number(s) in place on...Ch. 9 - Selection sort places ______ number(s) in place on...Ch. 9 - Prob. 15RQECh. 9 - Prob. 16RQECh. 9 - Why is selection sort more efficient than bubble...Ch. 9 - Prob. 18RQECh. 9 - Prob. 19RQECh. 9 - Prob. 20RQECh. 9 - Prob. 21RQECh. 9 - Charge Account Validation Write a program that...Ch. 9 - Lottery Winners A lottery ticket buyer purchases...Ch. 9 - Lottery Winners Modification Modify the program...Ch. 9 - Batting Averages Write a program that creates and...Ch. 9 - Hit the Slopes Write a program that can be used by...Ch. 9 - String Selection Sort Modify the selectionSort...Ch. 9 - Binary String Search Modify the binarySearch...Ch. 9 - Search Benchmarks Write a program that has at...Ch. 9 - Sorting Benchmarks Write a program that uses two...Ch. 9 - Sorting Orders Write a program that uses two...Ch. 9 - Ascending Circles Program 8-31 from Chapter 8...Ch. 9 - Modified Bin Manager Class Modify the BinManager...Ch. 9 - Using Files-Birthday List Write a program that...Ch. 9 - Prob. 14PCCh. 9 - Using Files-String Selection Sort Modification...Ch. 9 - Using Vectors String Selection Sort Modification...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Gas Prices In the student sample program files for this chapter, you will find a text file named GasPrices.txt....
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
What are the advantages in implementing a language with a pure interpreter?
Concepts Of Programming Languages
Open the products project and complete the StockManager class through this and the next few exercises. StockMan...
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Write a program to print the corresponding Celsius to Fahrenheit table.
C Programming Language
Describe what a compiler does with a programs source code.
Starting Out with Java: Early Objects (6th Edition)
(Factorials) Factorials are used frequently in probability problems. The factorial of a positive integer n (wri...
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Randomize_it Write a function in C++ that takes an array as a parameter and then randomize that array, i.e. shuffles the position of the elements in random order. To randomize the array your function should perform random 100 swaps of any two elements in the array. Return the randomized array from the function.vector<int> randomize(vector<int> input){// code here}arrow_forwardExercise 1: //The max function the max between a and b, it returns a if a == //b public double max(double a, double b); //The mult function returns the result of a * b public double mult(double a, double b); //The exist in array function returns the index of the element //‘a’ if //‘a’ exist in array ‘arr’ otherwise returns ‘-1’ public int existsInArray(int [] arr, int a); //Are array equals method compares two arrays and returns true // if the elements of array ‘a’ are equal to elements of array // ‘b’, element by element. If equals it returns 0, it returns - // 1 if not public int areArrayEquals(int [] a, int [] b); Devise four executable test cases for every method in the JUnit notation. See the attached handout for a refresher on the notation.arrow_forwardWrite a function namedisInt that hasone parm, a stringand returnsanint. The function should return true (in the C sense) if the string contains an int (all characters in the string are digits) and return false (in the C sense) otherwise. USE POINTER NOTATION INSTEAD OF ARRAY NOTATION. NO BRACKETS.arrow_forward
- String [] plants = newstring [] {“onions”, “carrots”, “peas”, “tomatoes”, “bananas”, “lemons”}; Using the array above , write code that 1. Prints the elements of the array in the order they appear in the array using a lambda function 2. Prints the elements of the array in descending order using a Linq function 3. Prints the elements of the array in ascending order using a linq fucntion 4. Prints the elements of the array that contain “ba” using a linq functionarrow_forwardWrite a python code 2) Write a function listsort which accepts a list as a parameter, and sorts it in ascending order. You can use any standard sorting algorithm, but don’t use built-in sort methods and functions. The function must sort and return the list.arrow_forwardDon't copy. Posted answer is wrongarrow_forward
- Part 3 – Longest Common Sequence This part requires that you implement a C function that takes in as parameters two arrays and their sizes. This function is required to find the longest common sequence of numbers in these arrays. The prototype of the function MUST be: void longestMutualSequence (int firstArr[), int secondArr[], int sizeA, int sizeB); For example, if you have int a[] = {1, 2, 3, 4, 1000, 90, 100, 110, 200, 202}; and int b[] = {1, 1, 2, 3, 90, 100, 110, 200, 202, 600};, your function should output. Longest Common Sequence is 90, 100, 110, 200, 202. If there are two common sequences of the same size, your function should print out the first common sequence found.arrow_forwardReverse ArrayWrite a function that accepts an int array and the array’s size as arguments. The function should create a copy of the array, except that the element values should be reversedin the copy. The function should return a pointer to the new array. Demonstrate thefunction in a complete program.arrow_forwardQuestion > Not complete Marked out of 1.50 Flag question Previous page Write a recursive function named get_palindromes (words) that takes a list of words as a parameter. The function should return a list of all the palindromes in the list. The function returns an empty list if there are no palindromes in the list or if the list is empty. For example, if the list is ["racecar", "hello", "noon", "goodbye"], the function should return ["racecar", "noon"]. A palindrome is a word that is spelled the same forwards and backwards. Note: The get_palindromes() function has to be recursive; you are not allowed to use loops to solve this problem. For example: Test words = ["racecar", "hello", "noon", "goodbye", "test", 'aibohphobia'] ['racecar', 'noon', 'aibohphobia'] print (get_palindromes (words)) print (get_palindromes ([])) print (get_palindromes (['this', 'is', 'test'])) Answer: (penalty regime: 0, 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50 %) Result Precheck Check [] [] Next pagearrow_forward
- Exercise Objectives Problem Description Write a program that reads a string and mirrors it around the middle character. Examples: abcd becomes cdab. abcde becomes deCab AhmadAlami becomes AlamiAhmad Page 1 of 2 Your program must: • Implement function void reflect (char* str) which receives a string (array of characters) and mirrors it. This function does not print anything. • Read from the user (in main()) a string and then print the string after calling function reflect(). • Use pointers and pointer arithmetic only. The use of array notation and/or functions from the string.h library is not allowed.arrow_forwardsolition in C++arrow_forwardMatrix Addition• Write an addition function that accepts two 2D numpy arrays, andreturns the sum of the two (if they are the same size). This functionshould test that the arrays are the same size before performing theaddition. If the arrays are not the same size, the function shouldreturn -1. solve in pythonarrow_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
1.1 Arrays in Data Structure | Declaration, Initialization, Memory representation; Author: Jenny's lectures CS/IT NET&JRF;https://www.youtube.com/watch?v=AT14lCXuMKI;License: Standard YouTube License, CC-BY
Definition of Array; Author: Neso Academy;https://www.youtube.com/watch?v=55l-aZ7_F24;License: Standard Youtube License