public static void mystery(int level) { if (level == 0) { System.out.print("*"); } else { System.out.print("["); mystery(level - 1); System.out.print(","); mystery(level - 1); System.out.print("]"); }
Show the output that would be produced by the following calls
public class Demo { public static void main(String[] ags) { System.out.println( fun(5) ); } public static int fun(int n) { if (n == 0) return 1; else return n + fun(n/2); } }
and predict the output
##### #### ### ## #
# ## ### #### #####
public void removeAll(Object keyItem, Node current)
public void removeAllGreaterItems(Comparable keyItem, Node current)
public void pattern(int[] input)
that takes an array of integers input and prints it out input.length times. The print must be in the following specific order: each line starts at a new element and wraps around to the beginning of the array (if needed) until each element has been printed out.
This sample output occurs when the input is the array {0, 1, 2, 3, 4}
:
0 1 2 3 4 1 2 3 4 0 2 3 4 0 1 3 4 0 1 2 4 0 1 2 3