


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Exam; Class: Full Course Title: Program Design and Development; Subject: COMPUTER SCIENCE; University: University of Arizona; Term: Fall 2006;
Typology: Exams
1 / 4
This page cannot be seen from the preview
Don't miss anything!



public void mystery(String s, int digit) { if(digit <= 1) System.out.println(digit); else { s = s + "<"; mystery(s, digit - 2); System.out.println(s + digit); } }
_____mystery(0) _____mystery(1) _____mystery(2) _____mystery(3) _____mystery(4) public int mystery(int n) { if (n <= 0) return 1; else return 3 + mystery(n - 1); }
________ mysteryTwo("T") ________ mysteryTwo("ab") ________ mysteryTwo("123") public String mysteryTwo(String s) { if (s.length() == 0) return ""; else return mysteryTwo(s.substring(1, s.length())) + "/" + s.charAt(0); }
public static void stars(int n) { if (n > 1) stars(n-1); for (int i = 0; i < n; i++) System.out.print("*"); System.out.println(); }
goingUp(1, 5); // 1 2 3 4 5 goingUp(2, 7); // 2 3 4 5 6 7 goingUp(3, 3); // 3