Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the missing number.
Use a hash table to store the presence of each number.
Sort the array and find the missing element.
Calculate the sum of all numbers from 0 to n and subtract the sum of the array elements.
Use the XOR operation to find the missing number.
Given an array of n integers, find three elements in the array such that the sum is closest to a given target number. Return the sum of the three integers.
Use three nested loops to iterate through all possible triplets.
Use dynamic programming to store the closest sum for all subarrays of size three.
Use a hash table to store the sum of all pairs of elements.
Sort the array and use two pointers to find pairs of elements with a sum close to the target minus the current element.
Which sorting algorithm is the MOST suitable for sorting a massive dataset that cannot fit entirely in RAM?
External Merge Sort
Merge Sort
Bubble Sort
Quick Sort
What is a key advantage of Radix Sort over comparison-based sorting algorithms like Quick Sort and Merge Sort?
Radix Sort guarantees stability, while Quick Sort and Merge Sort do not.
Radix Sort is always more space-efficient than comparison-based algorithms.
Radix Sort can achieve better than O(n log n) time complexity in certain cases.
Radix Sort is generally more suitable for sorting strings than numerical data.
When is Bucket Sort LEAST likely to be an efficient sorting algorithm?
The elements are integers within a known range.
The data is heavily skewed towards a few buckets.
The dataset is very large and sparse.
The data is uniformly distributed.
Which of the following array operations has an average-case time complexity that differs from its worst-case time complexity?
Accessing an element at a given index.
Inserting an element at the beginning of a dynamic array (implemented with reallocation).
Searching for a specific value in a sorted array.
Deleting an element from the end of an array.
You are given an array of integers and a target sum. Find all unique quadruplets in the array that sum up to the target sum.
Use four nested loops to iterate through all possible combinations of four elements.
Sort the array and use two pointers to find pairs of elements that sum up to a specific value.
Use a backtracking algorithm to explore all possible combinations of elements.
You are given an unsorted array of integers where each element represents the height of a bar in a histogram. Find the largest rectangular area in the histogram.
Sort the array and calculate the area for each subarray.
Use dynamic programming to store the maximum area ending at each index.
Iterate through the array and maintain a stack to track potential rectangle heights.
Use a divide and conquer approach to find the minimum element in each subarray.
What is the time complexity of Bucket Sort in the average case, assuming uniformly distributed data and a fixed number of buckets?
O(log n)
O(n)
O(n log n)
O(n^2)
You need to perform matrix multiplication on two large matrices, A and B, where A is of size M x N and B is of size N x P. You have multiple machines available for distributed computing. Which approach would likely yield the BEST performance improvement?
Divide matrix A into row blocks and distribute each block with a copy of B to different machines.
Divide both matrices A and B into smaller, equally sized submatrices and distribute the computation of these submatrices across the machines.
Divide matrix B into column blocks and distribute each block with a copy of A to different machines.
Performing the matrix multiplication sequentially on a single machine without any distribution.