Question: public class RecursiveMethods { // This method takes an int as the parameter and estimates the result of the // MadhavaLeibniz series. The result is
public class RecursiveMethods
{
// This method takes an int as the parameter and estimates the result of the
// MadhavaLeibniz series. The result is then considered as an approximation
// of pi/4. The method returns this value (pi/4).
public double computePI(int n)
{
// TODO: implement this method
return -1.0; // replace this statement with your own return
}
// This method takes a character stack and converts all lower case letters
// to upper case ones.
public void upperStackRec(CharStack s)
{
// TODO: implement this method
}
// This method reads a string and returns the string in the reversed order.
public String reverseStringRec(String s)
{
// TODO: implement this method
return "dummy string"; // replace this statement with your own return
}
// This method takes as parameters a reference to the head of a linked list, a
// position specified by n, and a key. It returns the number of occurrences
// of the key in the linked list beginning at the n-th node. If n = 0, it means
// you should search in the entire linked list. If n = 1, then you should skip
// the first node in the list.
public int numOccurrencesRec(LNode node, int n, int key)
{
// TODO: implement this method
return -1; // replace this statement with your own return
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
