Recursion
int sum(int n)
1
, 2
, ..., n
.
long factorial(int n)
n
, n! = 1 * 2 * ... * n
.
String reverse(String s)
s
in reverse order. For example,
reverse("banana")
returns "ananab"
.
String replace(char c, char with, String s)
s
with all characters equal to c
replaced with the
character with
. For example,
replace('a', 'u', "banana")
returns "bununu"
.
int binarySearch(List<String> t, String s)
s
in a sorted list
t
of strings. Binary search recursively examines the middle
element of the list to determine which half of the list the target word
s
must lie in (much like the bisection method for root finding).
Your method should return the index of the string s
if
it is in the list, otherwise it should return -1.
Coming soon.
Coming soon.