100
200
300
100

What is wrong with the following code?

ArrayList<Integer> list = new ArrayList<>();

list.add("string");

A string is being added to a list of Integers

100

Q: T/F A constructor of a subclass calls the constructor of its superclass if super() is not explicitly written.

 True

100

What is time complexity of binary search?

a. O(nlogn), b. O(logn), c. O(logbase2n), d. O(nlogbase2n)

b. O(logn)

200

int[] arr = new int[20];

for (int i = 0; i < arr.length; i++) arr[i] = 2 * i;

int binarySearch(int[] A, int low, int high, int key) {

    if (low > high) return -1;

    int mid = (low + high) / 2;

    if (A[mid] == key) return mid;

    else if (A[mid] < key) return binarySearch(A, mid + 1, high, key);

    else return binarySearch(A, low, mid - 1, key);

}

How many times is binarySearch() called (including the first call) when binarySearch(arr, 0, arr.length - 1, 14) is called?

A. 3, B. 4, C. 5, D. 6

B. 4

200

What technique is used to optimize recursion? a. abstraction, b. tabulation, c. fast Fourier transform, d.memoization

memoization

200

A merge sort on an array of 12 elements will merge subarrays how many times? a. 11, b. 12, c. 8, d. 16

11

300

What is the process of simplifying complex systems by focusing on essential features while hiding unnecessary details?

abstraction

300

What structure is used to represent non-linear recursion?

tree

300

What will be the output of the following code segment (assume class+method are properly implemented)?

ArrayList<integer> list = new ArrayList<>();

list.add(3);

list.add(4);

list.add(5);

list.remove(1);

System.out.println(list);  

error because integer should be Integer

M
e
n
u