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.

45 lines
1.5 KiB

6 years ago
  1. // The RecursiveMethods class that implements several recursive solutions
  2. // Your name here
  3. public class RecursiveMethods
  4. {
  5. // This method calls the sumSquareRec method and returns the sum of the
  6. // squares of the elements in the array.
  7. public int sumSquares(int[] A)
  8. {
  9. // Do not make any changes to this method!
  10. return sumSquaresRec(A, 0);
  11. }
  12. // This method takes an integer array as well as an integer (the starting
  13. // index) and returns the sum of the squares of the elements in the array.
  14. public int sumSquaresRec(int[] A, int pos)
  15. {
  16. // TODO: implement this method
  17. return -1; // replace this statement with your own return
  18. }
  19. // This method takes a character stack and converts all lower case letters
  20. // to upper case ones.
  21. public void upperStackRec(CharStack s)
  22. {
  23. // TODO: implement this method
  24. }
  25. // This method reads a string and returns the string in the reversed order.
  26. public String reverseStringRec(String s)
  27. {
  28. // TODO: implement this method
  29. return "dummy string"; // replace this statement with your own return
  30. }
  31. // This method takes a reference to the head of a linked list.
  32. // It returns the reference to the head of the linked list in the reversed order.
  33. public LNode reverseListRec(LNode head)
  34. {
  35. // TODO: implement this method
  36. return new LNode(-1); // replace this statement with your own return
  37. }
  38. }