Final answer:
This answer provides a step-by-step explanation of how to implement the required recursive methods for Lab 8, including checking for duplicates in a string, evaluating arithmetic expressions with single-digit operands and operators, and finding the index of a substring in a string.
Step-by-step explanation:
1. boolean duplicate(String s):
To check if the 2nd half of string s is a copy of the 1st half, we can use recursion by comparing the characters at corresponding positions in the two halves. If the characters don't match, we return false. If the lengths of the two halves become 0, we return true as all characters in the halves have been successfully compared.
2. int evalAS1(String e):
To evaluate the arithmetic expression e, we can use recursion by splitting the expression into two parts: the left operand and the right operand. We can recursively evaluate the left operand and the right operand, and then perform the appropriate operation based on the operator in the middle.
3. int index of(String s1, String s2):
To find the leftmost position of string s2 in string s1, we can use recursion by checking if the first character of s2 matches the first character of s1. If so, we recursively compare the remaining characters of s1 and s2. If not, we recursively search for s2 in the remaining characters of s1.