Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134448282
Author: Walter Savitch, Kenrick Mock
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 Java function displayOutIn that displays two items from an array list at one instance from out-to-in. until one or last two items displayed and the process stops. For example, given array A = {15, 74, 106, 10, 9, 86, 34} the displayOutIn function displays the following:
15, 34
74, 86
106, 9
10
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]
/**
* PROBLEM 3: The following function draws miskey mouse, if you call it like
* this from main:
*
* draw (.5, .5, .25);
*
* Change the code to draw piskey moose instead. Your solution should be
* recursive.
* Before picture:
* http://fpl.cs.depaul.edu/jriely/ds1/images/MickeyMouse.png After picture:
* http://fpl.cs.depaul.edu/jriely/ds1/images/MickeyMoose.png
* You may not use any "fields" to solve this problem (a field is a variable
* that is declared "outside" of the function declaration - either befor
* or after).
*/
public static void draw (double centerx, double centery, double radius) {
// TODO
if (radius < .e005) return;
StdDraw.setPenColor (StdDraw.LIGHT_GRAY);
StdDraw. filledCircle (centerx, centery, radius);
StdDraw.setPencolor (StdDraw.BLACK);
StdDraw.circle (centerx, centerY, radius);
double change = radius * 0.90;
StdDraw.setPencolor (StdDraw.LIGHT_GRAY);
StdDraw.filedCircle (centerx + change, centery + change, radius / 2);
StdDraw.setPenColor (StdDraw.BLACK);…
Chapter 14 Solutions
Problem Solving with C++ (10th 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
The following is a multiplication problem in traditional base ten notation. Each letter represents a different ...
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Consider the following skeletal C program: void fun1(void); / prototype / void fun2(void); / prototype / void f...
Concepts Of Programming Languages
In Exercises 33 through 40, determine the output displayed in the list box by the lines of code.
Introduction To Programming Using Visual Basic (11th Edition)
Figure 1-30 shows the Visual Studio IDE. What are the names of the four areas indicated in the figure? Figure 1...
Starting Out With Visual Basic (8th Edition)
1 void product() { 2int, a = 6; 3int b = 5; 4int c = 4; 5int result = a b c; 6System.out.printf("Result is %d...
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Why are field values sometimes coded?
Modern Database Management
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
- Q 3. Write a recursive function which compares two strings lexicographically, without using any predefined string functions from header file. Lexicographical order means alphabetical order as present in a dictionary, where a string which is greater - appears later in the dictionary. Also write main () function. It returns -1 if string 1 is smaller than string 2 It returns 1 if string 1 is greater than string 2 It returns 0 if both the strings are equal. For example: Programming Language :- C If string 1 is "madan" and string 2 is "madams" it returns 1 If string 1 is "aaaaba" and string 2 is "aaaabz" it retruns -1 If string 1 is "abzdefz" and string 2 is "abzca" it returns 1arrow_forwardIn 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…arrow_forward1. The sorted values array contains 16 integers 5, 7, 10, 13, 13, 20, 21, 25, 30,32, 40, 45, 50, 52, 57, 60. Indicate the sequence of recursive calls that are made tobinaraySearch, given an initial invocation of binarySearch(32, 0, 15).show only the recursive calls. For example, initial invocation is binarySearch(45,0,15)where the target is 45, first is 0 and last is 15.arrow_forward
- Write a RECURSIVE function, without using any loops, that prints the contents of a matrix with 3 columns. The function should take the matrix and the number of rows as arguments. void print_matrix(int arr[][3], int num_rows);arrow_forwardin c++arrow_forwardWrite the C++ full main.cpp for the first screenshot titled, "Project 25.1" Then write full main.cpp mystring.h, and mystring.cpp for the second screenshot titled, "Project 25.2"arrow_forward
- 12. Consider the recursive function int gcd( int a, int b) int gcd( int a, int b){ if (b > a) return gcd(b,a); if ( b == 0 ) return a; return gcd( b, a% b); } How many invocation (calls) of the gcd() function will be made by the call gcd(72, 30)?arrow_forwardWrite a recursive function maxArrayList (ArrayList A, int first, int last) that receives an ArrayList A, first index, last index and returns the largest integer number in the ArrayList A public static int maxArrayList (ArrayList A, int item) that receives an ArrayList A, an integer called item and returns the number of times that item occurs in A public static int searchArrayList (ArrayListarrow_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_forwardIn C languagearrow_forwardCreate 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_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_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