C++ How to Program (Early Objects Version)
10th Edition
ISBN: 9780134448824
Author: Paul Deitel; Harvey M. Deitel
Publisher: Pearson Education (US)
expand_more
expand_more
format_list_bulleted
Question
Chapter 7, Problem 7.31RE
Program Plan Intro
- Int a[] used as a input array
- Int n is a size of an array
- Minvaluefunction used to find the minimun value
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
(Recursive Greatest Common Divisor) The greatest common divisor of integers x and y isthe largest integer that evenly divides both x and y. Write a recursive function gcd that returns thegreatest common divisor of x and y. The gcd of x and y is defined recursively as follows: If y is equalto 0, then gcd(x, y) is x; otherwise gcd(x, y) is gcd(y, x % y), where % is the remainder operator.
: Write a recursive function to multiply two positive integers without usingthe * operator (or / operator). You can use addition, subtraction, and bit shifting, but you shouldminimize the number of those operations.
Question 4: (Find the minimum value in an array) Write a program that include a
recursive function "recursiveMinimnm" that takes an integer array and the array size as
arguments and returns the smallest element of the array. The function should stop
processing and return when it receives an array of one element.
Answer
(2.5)
Chapter 7 Solutions
C++ How to Program (Early Objects Version)
Ch. 7 - Exercises 7.6(Fill in the Blanks) Fill in the...Ch. 7 - (True or False) Determine whether each of the...Ch. 7 - (Write C++ Statements) Write C++ statements to...Ch. 7 - (Two-Dimensional array Questions) Consider a...Ch. 7 - (Salesperson Salary Ranges) Use a one-dimensional...Ch. 7 - (One-Dimensional array Questions) Write statements...Ch. 7 - (Find the Errors) Find the error(s) in each of the...Ch. 7 - (Duplicate Elimination with array) Use a...Ch. 7 - Prob. 7.14ECh. 7 - Prob. 7.15E
Ch. 7 - (Dice Rolling) Write a program that simulates...Ch. 7 - ( What Does This Code Do?) What does the following...Ch. 7 - (Craps Game Modification) Modify the program of...Ch. 7 - (Converting vector Example of Section 7.10 to...Ch. 7 - Prob. 7.20ECh. 7 - (Sales Summary) Use a two-dimensional array to...Ch. 7 - (Knight's Tour) One of the more interesting...Ch. 7 - (Knight's Tour: Brute Forty Approaches ) In...Ch. 7 - (Eight Queens) Another puzzler for chess buffs is...Ch. 7 - (Eight Queens: Brute Force Approaches) In this...Ch. 7 - Prob. 7.26ECh. 7 - (The Sieve of Eratosthenes) A prime integer is any...Ch. 7 - Prob. 7.28RECh. 7 - (Eight Queens) Modify the Eight Queens program you...Ch. 7 - (Print an array) Write a recursive function...Ch. 7 - Prob. 7.31RECh. 7 - Prob. 7.32RECh. 7 - (Maze Traversal) The grid of hashes (#) and dots...Ch. 7 - Prob. 7.34RECh. 7 - Making a Difference 7.35 (Polling) The Internet...
Knowledge Booster
Similar questions
- (Recursive Binary Search) Write a recursive method RecursiveBinarySearch to perform abinary search of the array. The method should receive the search key, starting index, endingindex and array A as arguments. If the search key is found, return its index in the array. If thesearch key is not found, return -1.int RecursiveBinarySearch(int search, int start, int end, int[] A)arrow_forward4. CodeW X For func X C Solved b Answer x+ https://codeworkou... ... [+) CodeWorkout X271: Recursion Programming Exercises: Minimum of array For function recursiveMin, write the missing part of the recursive call. This function should return the minimum element in an array of integers. You should assume that recursiveMin is initially called with startIndex = 0. Examples: recursiveMin({2, 4, 8}, 0) -> 2 Your Answer: 1 public int recursiveMin(int numbers[], int startIndex) { numbers.length - 1) { if (startIndex 2. return numbers[startIndex]; } else { return Math. min(numbers[startIndex], >); 5. { 1:11 AM 50°F Clear 12/4/2021arrow_forwardUnder your module imports, paste the following definitions: (define WIDTH 300) (define HEIGHT 160) (define ES (empty-scene WIDTH HEIGHT)) (define (next-size s) (/ s 2)) Write a tail-call recursive function called circles in Racket. This function should take two numbers, x and size, and a Scene scn. If size is less-than or equal to 2, then your function returns the scn unchanged (base case). Otherwise, your function should place a circle in the Scene that results from a recursive call to circles with x shifted by (+size (next-size size)), a new size of (next-size size), and using the original Scene. After evaluating (circles 100 48 ES), your function should output this image of five blue circles, in this order, with the first circle at (x,y) coordinate position (100, 80):arrow_forward
- Exercise 1: (Design of algorithm to find greatest common divisor) In mathematics, the greatest common divisor (gcd) of two or more integers is the largest positive integer that divides each of the integers. For example, the gcd of 8 and 12 is 4. Why? Divisors of 8 are 1, 2, 4, 8. Divisors of 12 are 1, 2, 4, 6, 12 Thus, the common divisors of 8 and 12 are 1, 2, 4. Out of these common divisors, the greatest one is 4. Therefore, the greatest common divisor (gcd) of 8 and 12 is 4. Write a programming code for a function FindGCD(m,n) that find the greatest common divisor. You can use any language of Java/C++/Python/Octave. Find GCD Algorithm: Step 1 Make an array to store common divisors of two integers m, n. Step 2 Check all the integers from 1 to minimun(m,n) whether they divide both m, n. If yes, add it to the array. Step 3 Return the maximum number in the array.arrow_forwardProgramming Language C Note:No Need for Detailed Explanation. The Answer is Enough For Me.Solve according to this information. (No: 2012010206083)arrow_forwardCodeW X b For func x C Solved X b Answer X https://codeworkou... CodeWorkout X270: Recursion Programming Exercise: Count Characters For function countChr() write the missing part of the recursive call. This function should return the number of times that the letter "A" appears in string "str". Recall that str.substring(a) will return the substring of str from position a to the end of str, while str.substring (a, b) will return the substring of str starting at position a and continuing to (but not including) the character at position b. Examples: countChr ("ctcoWCAt") -> 1 Your AnsSwer: 1 public int countChr(String str) { 2. if (str.length() return 0; } (0 4. { int count = 0; www. 5. 9. if (str.substring(0, 1).equals("A")) { count = 1 7. { 9. return count + > 1:10 AM 50°F Clear 12/4/2021 呼arrow_forward
- 2: - Write a recursive function that takes an array and a callback function and returns True if any value of that array returns True from that callback function otherwise returns False. As a callback funtion for this problem, assume that the callback function is used to check if a given input is an even number. Anals, the running time of the algorithm 3: Recursive Linear Searcharrow_forwardCalculation "a" was used for loop to calculate the sum of squares of values in this list: 1, 7, 8, 6, 11 (The answer was 271) (Question 1) Create recursive function to do the same calculation "a" in the above. (The function input will be the list. Each recursion, you are going to send a sub-list with one less item from the list) (Hint:There are many ways to do sorting. Create a function to perform bubble sorting as descried in this tutorial: (https://www.geeksforgeeks.org/bubble-sort/) . The algorithm should stop when there are no swaps in the last iteration.)arrow_forward17: recursion.cpp) Write two recursive integer functions. The first function should calculate factorials using the definition 0! = 1 and n! = (n-1)! x n. In addition, if n is too large it should be able to detect integer overflow before it happens. The next function should calculate the greatest common factor (gcf) of two numbers. If the second number is zero, then the gcf is the other number. Otherwise, the gcf of a and b is the same as the gcf of b and a mod b.arrow_forward
- I cant use the sqrt() library functionarrow_forward(Sort three numbers) Write the following function to display three numbers in increasing order: def displaySortedNumbers(num1, num2, num3): Write a test program that prompts the user to enter three numbers and invokes the function to display them in increasing order. Here are some sample runs:arrow_forward[Fish Tank] You play with a clown fish that has an initial size so. The fish can eat other fish in a tank organized in m columns and n rows. The fish at column i and row j has a positive size si,j. When your fish eats another fish, it grows by that amount. For example, if your clown fish has a size of 10 and eats a fish of size 5, it becomes of size 15. You cannot eat a fish that is bigger than your size. The game starts by eating any fish in the first (left-most) column that is not bigger than yours. After that, you advance one column at a time by moving right. You have only three allowed moves. You either stay at the same row, move one row higher or one row lower. You will always move to the right. Thus, you will make exactly m moves to advance from left to right. Your goal is to exit the fish tank from the right with the biggest possible size. The figure below shows an example with the best answer highlighted. In this case, the final fish size is 71 (10+8+7+24+22). You are required…arrow_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