Write the missing base case for function largest
. Function largest
should find the largest number in array numbers
. When largest
is first...
Recursion
Score: 0 / 40.0
Exercises
For function multiply
, write the missing base case condition and action. This function will multiply two numbers x
and y
. You can assume...
The greatest common divisor (GCD) for a pair of numbers is the largest positive integer that divides both numbers without remainder. For...
For function sumtok
, write the missing recursive call. This function returns the sum of the values from 1 to k
.
For function countChr()
write the missing part of the recursive call. This function should return the number of times that the letter "A"...
For function recursiveMin
, write the missing part of the recursive call. This function should return the minimum element in an array of...
For function isReverse
, write the two missing base case conditions. Given two strings, this function returns true if the two strings are...
Spherical objects, such as cannonballs, can be stacked to form a pyramid with one cannonball at the top, sitting on top of a square...
Write a recursive function named checkPalindrome
that takes a string as input, and returns true if the string is a palindrome and false...
Use the following recursive method:
public int mysteryMethod(int n) { if (n < 0) { return 5; } else { return mysteryMethod(n - 1) +...
Given a string, return true
if it is a nesting of zero or more pairs of parentheses, like "(())" or "((()))". Suggestion: check the first...
Given base
and n
that are both 1 or more, compute recursively (no loops) the value of base
to the n
power, so powerN(3, 2)
is 9 (3...
Given an array of int
s, compute recursively if the array contains somewhere a value followed immediately by that same value times 10....
Given a string, compute recursively a new string where all the 'x' chars have been removed.
Given a non-negative int n
, return the count of the occurrences of 7 as a digit, so for example 717 yields 2. (no loops). Note that mod (...
In mathematics, the Fibonacci numbers are the numbers in the following integer sequence, characterized by the fact that every number...