Sale!

Lab 2: Recursion (Fundamental) solved

Original price was: $35.00.Current price is: $35.00. $17.50

Category: You will receive a download link of the .ZIP file upon Payment

Description

5/5 - (1 vote)

1. Create a recursive function that accepts a String parameter, and substitute any of the
lowercase “a” (no applicable for uppercase “A”) found with “i” char. Example:
substituteAI (“flabbergasted “) → “flibbergisted ”
substituteAI (“Astronaut “) → ” Astroniut”
2. Write a recursive method called permuteString() that will find and print all the possibilities to
arrange the letters of a given word. Example:
Input String : “ABC”
Output Permutation :
ABC
ACB
BAC
BCA
CAB
CBA
Tips:
1) Take out the first char from String and permute the remaining chars.
If String = “ABC”
First char = A and remaining chars permutations are BC and CB.
2) Insert first char in the available positions in the permutations.
BC -> ABC, BAC, BCA
CB -> ACB, CAB, CBA
3) Then write a recursive function call to return the permutations and then another function call to insert
the first characters to get the complete list of permutations.
3. Write a recursive method called exponent(x,y) to perform exponentiation return xy
, assuming
y >= 0. Example:
exponent(10,3) → will produce an output of 1000
Method signature as follows:
public static long exponent(int x, int m) {
}