You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.5 KiB
46 lines
1.5 KiB
// The RecursiveMethods class that implements several recursive solutions
|
|
// Your name here
|
|
|
|
public class RecursiveMethods
|
|
{
|
|
// This method calls the sumSquareRec method and returns the sum of the
|
|
// squares of the elements in the array.
|
|
public int sumSquares(int[] A)
|
|
{
|
|
// Do not make any changes to this method!
|
|
return sumSquaresRec(A, 0);
|
|
}
|
|
|
|
// This method takes an integer array as well as an integer (the starting
|
|
// index) and returns the sum of the squares of the elements in the array.
|
|
public int sumSquaresRec(int[] A, int pos)
|
|
{
|
|
// TODO: implement this method
|
|
|
|
return -1; // 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 a reference to the head of a linked list.
|
|
// It returns the reference to the head of the linked list in the reversed order.
|
|
public LNode reverseListRec(LNode head)
|
|
{
|
|
// TODO: implement this method
|
|
|
|
return new LNode(-1); // replace this statement with your own return
|
|
}
|
|
}
|