Question: Java code please import java.util.Queue; import java.util.Stack; public class Recursion { /** * Write a recursive function that finds the index of s2 in s1.
Java code please
import java.util.Queue; import java.util.Stack;
public class Recursion {
/** * Write a recursive function that finds the index of s2 in s1. Do not use any * string functions except for .length(), .equals(), and .substring(). Do not use * any loops, or any data structures. * @param s1 * @param s2 * @return Returns the index of the first time that * s2 appears in s1 or -1 if s2 is not contained * in s1. */ public static int indexOf(String s1, String s2) { return -1; }
/** * Write a recursive function that removes the first k even numbers * from the stack. If there are less than k even elements in the stack, * just remove all even elements. Do not use any loops or data structures * other than the stack passed in as a parameter. * @param stack * @param k * @return Returns the number of elements removed from the stack. */here first k means k elements from top public static int removeEvenNumbers(Stack
/** * Write a recursive function that accepts an integer and * returns a new number containing only the even digits, in the same * order. If there are no even digits, return 0. Your function should * work for positive or negative numbers. You are NOT allowed * to use any data structures. You are not allowed to use Strings to * solve this problem either. * @param n * @return The input with only the even digits remaining in the same * order. */ public static int evenDigits(int n) { return 0; }
/** * Write a recursive function that evaluates a Queue
/** * Write a recursive function that accepts a stack of integers and * replaces each int with two copies of that integer. For example, * calling repeatStack and passing in a stack of { 1, 2, 3} would change * the stack to hold { 1, 1, 2, 2, 3, 3}. Do not use any loops. Do not use * any data structures other than the stack passed in as a parameter. * @param stack */ public static void repeatStack(Stack
/** * Write a recursive function that accepts a Queue
}
please help, I will give you a thumb up
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
