public V put(K key, V value) { for (Entry e : list) { if (e….

public V put(K key, V value) { for (Entry e : list) { if (e.getKey().equals(key)) { V old = e.getValue(); e.setValue(value); return old; } } list.add(new Entry(key, value)); return null; } What is the worst-case time complexity of the put operation shown above for a map with n entries?

In the Merge-Sort algorithm, which lines of code are *direct…

In the Merge-Sort algorithm, which lines of code are *directly* responsible for its O(n) auxiliary space complexity? public void merge(K[] S, K[] S1, K[] S2, Comparator comp) { // … merge logic … } public void mergeSort(K[] S, Comparator comp) { int n = S.length; if (n < 2) return; // Base case int mid = n / 2; K[] S1 = Arrays.copyOfRange(S, 0, mid); // LINE A K[] S2 = Arrays.copyOfRange(S, mid, n); // LINE B mergeSort(S1, comp); // LINE C mergeSort(S2, comp); // LINE D merge(S, S1, S2, comp); // LINE E }

Identify the missing step in the removeMin method below: pu…

Identify the missing step in the removeMin method below: public E removeMin() { if (heap.isEmpty()) return null; E min = heap.get(0); int lastIndex = heap.size() – 1; // MISSING LINE HERE heap.remove(lastIndex); if (!heap.isEmpty()) { downheap(0); } return min; }