Quiz 4

Wednesday

With a piece of paper, write down your name and answers to the following questions.

Consider the following program?

public final class Program {
	public static void main(final String[] args) {
		System.out.println("mysteriousOne output:");
		mysteriousOne(3);

		System.out.println("mysteriousTwo output:");
		mysteriousTwo(3);

		System.out.println("mysteriousThree output:");
		mysteriousThree(3);
	}

	private static void mysteriousOne(final int n) {
		System.out.println(n);
		if (n > 1)
			mysteriousOne(n - 1);
	}

	private static void mysteriousTwo(final int n) {
		if (n > 1)
			mysteriousTwo(n - 1);
		System.out.println(n);
	}

	private static void mysteriousThree(final int n) {
		System.out.println(n);
		if (n > 1)
			mysteriousThree(n - 1);
		System.out.println(n);
	}
}
  1. What is the base case for the mysteriousThree method?

    Answer: n <= 1.

  2. What is the recursive case for the mysteriousThree method?

    Answer: n > 1.

  3. What is the output of this program?

    Answer:

    mysteriousOne output:
    3
    2
    1
    mysteriousTwo output:
    1
    2
    3
    mysteriousThree output:
    3
    2
    1
    1
    2
    3

Student Performance and Statistics

A histogram of student performance on percentage grades for Quiz 4 on Wednesday.

100% 3 90 - 99% 0 80 - 89% 1 70 - 79% 0 60 - 69% 4 50 - 59% 0 40 - 49% 3 30 - 39% 0 20 - 29% 5 10 - 19% 0 0 - 9% 2

A table showing the average performance for each question in Quiz 4 on Wednesday.

Q1 0.5 / 1 Q2 0.6 / 1 Q3 1.2 / 3