quiz2 Flashcards

1
Q

Each class provides its own implementation of hashCode()

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Which of the following sorting algorithm is NOT stable?

A

b.
Selection sort

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Object class contains hashCode() method with its default implementation

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

The given illustration is about __________.

A

a.
Merge sort

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

A hash table uses a hash function (algorithm) to compute an index

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Which of the following sorting algorithms has the lowest worst-case complexity?

A

d.
merge sort

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

The following code is an implementation of _________________.

A

c.
Top-down reheapify (sink) implementation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

The next statements are about _______ sort.

Select a pivot point which could be: First element, Last element, Middle element in the sequence

Partition the other elements into two sub-arrays, according to whether they are less or greater than the pivot point

A

a.
Quick

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is represented in the Figure below:

A

c.
Hash Table

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Which of the following sorting algorithms not has a worst-case time complexity of O(n^2)?

A

c.
Merge Sort

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Which sorting algorithm works by repeatedly selecting the largest remaining element and placing it at the beginning of the sorted portion of the array?

A

d.
Selection Sort

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Which of the following sorting algorithms can be used for sorting linked lists?

A

c.
Merge Sort

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

The following method is an implementation of ___________.

public static void XXX(int[] arr, int left, int right) {

if (left >= right) {

return;

}

int pivot = YYY(arr, left, right);

XXX(arr, left, pivot - 1);

XXX(arr, pivot + 1, right);

}

public static int YYY(int[] arr, int left, int right) {

int pivot = arr[right];

int i = left - 1;

for (int j = left; j < right; j++) {

if (arr[j] < pivot) {

  i++;

  int temp = arr[i];

  arr[i] = arr[j];

  arr[j] = temp;

}

}

int temp = arr[i + 1];

arr[i + 1] = arr[right];

arr[right] = temp;

return i + 1;

}

A

a.
Quick sort

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Which of the following sorting algorithm has best case time complexity of O(n^2)?

A

c.
insertion sort

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Which of the following sorting algorithms requires extra memory space to sort an array?

A

a.
Merge Sort

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

The capacity and load factor are parameters that affect the Hash Table performance

A

True

17
Q

Choose worst case of quick sort when the selected pivot point is always the smallest or largest

A

b.
O(n^2)

18
Q

The worst case running times of Insertion sort, Merge sort and Quick sort, respectively, are:

A

c.
Θ(n2), Θ(n log n) and Θ(n2)

18
Q

Insertion sort performs two operations: it scans through the list, comparing each pair of elements, and it swaps elements if they are out of order

A

False

18
Q

Quick sort running time depends on the selection of

A

b.
Pivot element