end Flashcards
Which sorting algorithm uses the divide-and-conquer approach?
c.
Quick Sort
In a graph with multiple connected components, how many times will BFS be called?
d.
The number of connected components
when an algorithm generates the same address for different identifiers it is known as
a.
Collisions
What data structure is used in DFS to keep track of the visited nodes?
d.
Stack
The capacity and load factor are parameters that affect the Hash Table performance
True
Which of the following techniques can be used to search an element in an unsorted array?
b.
Iterative linear search
What is the worst case runtime of linear search algorithm?
b.
O(n)
Each class provides its own implementation of hashCode()
False
Which of the following sorting algorithm has best case time complexity of O(n^2)?
b.
selection sort
What is the minimum number of edges required for a connected undirected graph with n vertices?
c.
n-1
In a weighted graph, which of the following algorithms can be used to find the shortest path from a source node to all other nodes?
d.
Dijkstra’s algorithm
Which of the following sorting algorithms not has a worst-case time complexity of O(n^2)?
a.
Merge Sort
Object class contains hashCode() method with its default implementation
True
Selected pivot point can be only first element in quick sort.
False
Which of the following methods can be used to search an element in a linked list?
d.
Iterative linear search
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.
Quick sort
Binary Search can be categorized into which of the following?
c.
Divide and conquer
Which of the following sorting algorithms has a best-case time complexity of O(n)?
a.
Merge Sort
Which of the following sorting algorithms requires extra memory space to sort an array?
c.
Merge Sort
Which of the following sorting algorithms has a time complexity of O(n*log(n)) in the average case?
d.
Merge Sort
Binary search algorithm is also called Bisection search method.
True
What is a heap in computer science?
d.
A data structure for efficiently finding the minimum or maximum element.