For function sumtok
, write the missing recursive call. This function returns the sum of the values from 1 to k
.
Search Results
Searching for: recursion
Individual Exercises
For function addOdd(n)
write the missing recursive call. This function should return the sum of all postive odd numbers less than or...
For function sumOfDigits
, write the missing recursive call. This function takes a non-negative integer and returns the sum of its digits....
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...
For function decToBinary
, write the missing parts of the recursion case. This function should return a string that stores the binary...
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...
Write a recursive function that takes a start index, array of integers, and a target sum. Your goal is to find whether a subset of the...
Pascal's triangle is a useful recursive definition that tells us the coefficients in the expansion of the polynomial (x + a)^n. Each...
Write a function in Java that uses recursion (no loops) to check if the String str
has any char a
. Return true
if it does and false
if it...
When a method is directly recursive, what does it call?
In mathematics, the Fibonacci numbers are the numbers in the following integer sequence, characterized by the fact that every number...
Use the following recursive method:
public int mysteryMethod(int n) { if (n < 0) { return 5; } else { return mysteryMethod(n - 1) +...
In mathematics, the Perrin Numbers are defined by the recursion relation
P(n) = P(n - 2) + P(n -3) for n > 2
with initial values
P(0)...
Write a method quicksort that takes in an ArrayList of integers and returns them in ascending order, using a quicksort style of sorting....
Write an algorithm that takes an ArrayList and uses a recursive binary search to return both the index of a given String, or -1 if the...
Design a recursive method for scrambling Strings of length 3 or more. It must swap the first and last character of the input String, then...
Write a function in Python called 'factorial()' that will take a positive integer as input and returns its factorial as output....
Write a function in C++ called 'factorial' that will take a positive integer as input and returns its factorial. In math, a factorial is...
Write a function in Ruby called 'factorial()' that will take a positive integer as input and returns its factorial as output. backwards.
...Write a function in Java called factorial(int n)
that will take a positive integer as input and returns its factorial as output. Your...
Write a function in Java called factorial(int n)
that will take a positive integer as input and returns its factorial as output. Your...
Write a function in Java called factorial(int n)
that will take a positive integer as input and returns its factorial as output. You will...