Problem Solving with C++ (9th Edition)
9th Edition
ISBN: 9780133591743
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 14, Problem 3P
Write a recursive version of the search function in Display 7.10 of Chapter 7.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a recursive function that returns the smallest integer in an array. Write a test program that prompts the user to enter a list of five integers and displays the smallest integer.
3.
Write a
recursive function that
ассepts
8x8 array of
an
characters that represents a maze. Each position can contain
either an X or a blank. Starting at position (0,1), list any path
through the maze to get to the location (7,7). Only horizontal
and vertical moves are allowed. If no path exists, write a
message indicating there is no path. Moves can be made only
to the locations that contain a blank. If an X is encountered,
that path is blocked and another must be chosen.
[6]
In java
Develop a function that accepts an array and returns true if the array contains any duplicate values or false if none of the values are repeated.
Develop a function that returns true if the elements are in decreasing order and false otherwise.
A “peak” is a value in an array that is preceded and followed by a strictly lower value. For example, in the array {2, 12, 9, 8, 5, 7, 3, 9} the values 12 and 7 are peaks. Develop a function that returns the number of peaks in an array of integers. Note that the first element does not have a preceding element and the last element is not followed by anything, so neither the first nor last elements can be peaks.
Develop a function that finds the starting index of the longest subsequence of values that is strictly increasing. For example, given the array {12, 3, 7, 5, 9, 8, 1, 4, 6}, the function would return 6, since the subsequence {1, 4, 6} is the longest that is strictly increasing.
Develop a function that takes a string…
Chapter 14 Solutions
Problem Solving with C++ (9th Edition)
Ch. 14.1 - Prob. 1STECh. 14.1 - Prob. 2STECh. 14.1 - Prob. 3STECh. 14.1 - Prob. 4STECh. 14.1 - Prob. 5STECh. 14.1 - If your program produces an error message that...Ch. 14.1 - Write an iterative version of the function cheers...Ch. 14.1 - Write an iterative version of the function defined...Ch. 14.1 - Prob. 9STECh. 14.1 - Trace the recursive solution you made to Self-Test...
Ch. 14.1 - Trace the recursive solution you made to Self-Test...Ch. 14.2 - What is the output of the following program?...Ch. 14.2 - Prob. 13STECh. 14.2 - Redefine the function power so that it also works...Ch. 14.3 - Prob. 15STECh. 14.3 - Write an iterative version of the one-argument...Ch. 14 - Prob. 1PCh. 14 - Prob. 2PCh. 14 - Write a recursive version of the search function...Ch. 14 - Prob. 4PCh. 14 - Prob. 5PCh. 14 - The formula for computing the number of ways of...Ch. 14 - Write a recursive function that has an argument...Ch. 14 - Prob. 3PPCh. 14 - Prob. 4PPCh. 14 - Prob. 5PPCh. 14 - The game of Jump It consists of a board with n...Ch. 14 - Prob. 7PPCh. 14 - Prob. 8PP
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
(Radiocarbon dating) Carbon taken from a purported relic of the time of Christ contained 4.6104 atoms of 14C pe...
Differential Equations: Computing and Modeling (5th Edition), Edwards, Penney & Calvis
Length Conversion Write a program to convert a U.S. Customary System length in miles, yards, feet, and inches t...
Introduction To Programming Using Visual Basic (11th Edition)
In what year was Plankalkl designed? In what year was that design published?
Concepts Of Programming Languages
Retail Price Calculator Write a program that asks the user to enter an items wholesale cost and its markup perc...
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Describe the purpose of the access key attribute and how it supports accessibility.
Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)
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
- Write a program that implements a recursive sequintial search. The search function should be done in a class. Wite a program that tests the code.arrow_forwardWrite a C++ Program using classes, functions (recursive and otherwise), arrays and other C++ commands that reads words from a file (one column only), storing them into an array. Once the array is sorted alphabetically ascending, the user is prompted to enter a word. The program reports whether or not the word was in the array of words. and its position on the array. If the word is found, the program should report the number of letters in that word.arrow_forwarda) Can you develop Java code.Create a recursive function to print all permutations of a string. For example, the permutation of the string "abc" is [abc, acb, bac, bca, cab, cba]. b) Revise the genericStack class to use an array instead of an ArrayList. Before adding a new element, make sure the array size is correct. If the current array is full, construct a new array twice the size, copy the elements, and add the new array. dont use aiarrow_forward
- Create a program using java data structures That has the user enter their pay rate; the program will require the employee to enter hours for two days ( they work two days a week); and the conversion must be done. via a recursive function (all calculation and display happen in a single function). Include an additional function to prompt the user for their numbers. Do NOT USE Stack ADT, ANY ADTs, or structures that we created in class. Employee - hoursWorked : int - payRate : double -Employee(void) Default constructor - has NO parameters and must NOT return anything. Sets both attributes to 0. -AddHours(hoursToAdd : int) : void Adds the given hours to add to the hoursWorked attribute. -SetPayRate(newPayRate : double) : void Changes the payrate attribute to the given new pay rate. -GetHoursWorked(void) : int {hoursWorked} Gives back the hoursWorked attribute -+ GetPayRate(void) : double {payRate} Gives back the payRate attribute. -GetGrossPay(void) : double {grossPay} Computes and…arrow_forwardIn C Programming, write a program that creates an array of N names. Each name has 5 exam scores. Output the names with the highest and lowest average scores. No using of Struct, no using of Pointers and No Global Declaration.arrow_forward1. Implement a class employee that has two data members name and salary. 2. Implement getter function for salary data member only. 3. Implement a modified selection sort function that takes an array of employees as an input and sort the array of employees by salary in descending order (employees with higher salaries should come first). 4. Determine the Big (0) complexity of the following code snippet (write the answer to this question as a comment in the top of your code (-SRR) file): Snippet 1: for (i = sum = 0; i < n; i++) sum += a[i): for (i = 0; i < n; i++){ for (j = 1, sum = a[0]; j <= i; j++) sum += a[]; cout<<"sum for subarray 0 through "<< i<" is *<arrow_forwardQ/ Write a program in C# that lets the user to define the number of rows and columns. Then, the program reads the matrix and finds the index of the even and odd numbers and display them with their corresponding indices. Use adequate messages during the program execution.arrow_forwardCreate a recursive function in a file called ab_equality.py: def ab_equal(n, k, current): Print out all of the strings of a's and b's of length n so that the number of a's and b's are equal. For n = 2, there's ab and ba. For n = 3 there are no strings since they'd have to have 2 a's and 1 b, or 2 b's a 1 a so not equal. For n = 4, there will be 6 of these strings, and for n = 5, zero again. Hint: use k to track the difference between a's and b's. So for instance if your current is aaabb then k should be equal to either 1 or -1 (your choice depending). When you call the function, you should call it from your main or testing function with the length in the n parameter, 0 should be put into the k parameter, and then an empty string will be passed in for current.arrow_forwardWrite in c++arrow_forwardUse Dr Racket please.arrow_forwardIn C Programming: Write a function printCourseRow() which receives a course pointer and prints all its fields as a single row. Use proper formatting so that when we print 2 or more courses as rows, the same members align below each other. Test the function, but don’t include the testing code in your homework.Upload a screenshot of a sample output.arrow_forwardUsing visual studio (C#) create a program, name it PRGYOURNAMEFA1, that implements a search and replace function recursively. Your program should allow a user to enter a string , a substring to be replaced in the entered string and a character/s to replace the found substring Program Structure1. A main class that implements the logic of the program – name this class TestSearchReplace2. Add a class named SearchReplace to the main class with two methods, including:a. SearchSubstring()- return methodb. ReplaceSubString() - void method The two method should be called using an object in the main class. DONT CREATE THE TWO METHODS IN THE MAIN CLASSSample Outputarrow_forwardarrow_back_iosSEE MORE QUESTIONSarrow_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
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