What are ints, doubles, booleans, etc.?
double[][] values = { {1.2, 9.0, 3.2},
{9.2, 0.5, 1.5},
{7.3, 7.9, 4.8}};
The value of values[2][1].
public int product(int n){
if(n == 1)
return 1;
else
return n * product(n - 2);
}
"Green Eggs And Ham".indexOf("g").
double[][] things = {{1.2, 9.0},
{9.2, 0.5},
{7.3, 7.9}};
The value of things.length.
-OR-
What is myText.substring(2, myText.length())?
public int mystery(int n){
if (n == 0)
return 1;
else
return 3 * mystery(n - 1);
}
String result = "abcdefgh".substring(2) + "hgfedcba".substring(5);
What is O(n2)?
int[][] m = {{1, 1, 1, 1},
{1, 2, 3, 4},
{2, 2, 2, 2},
{2, 4, 6, 8}};
int sum = 0;
for(int k = 0, k < m.length; k++)
sum = sum + m[m.length - 1 - k][1];
public int product(int n){
if (n <= 1)
return 1;
else
return n * product(n - 2);
}
String result = "adbcefg".substring(1,3 * "abcd".indexOf("acbcd".substring(2)) + 1)
int[][] arr = {{3, 2, 1}, {1, 2, 3}};
int value = 0;
for (int row = 1; row < arr.length; row++){
for(int col = 1; col < arr[0].length; col++){
if (arr[row][col] % 2 == 1)
arr[row][col] = arr[row][col] + 1;
if (arr[row][col] % 2 == 0)
arr[row][col] = arr[row][col] * 2;
}
}
}
{{3, 2, 1}, {1, 4, 8}}
public int redo(int i, int j){
if (i == 0)
return 0;
else
return redo(i/j, j) + 1;
}