What is the time complexity of accessing an element in a 2D array with 'm' rows and 'n' columns?
O(1)
O(log m + log n)
O(m + n)
O(m * n)
Which of the following sorting algorithms has the best average-case time complexity?
Bubble Sort
Merge Sort
Insertion Sort
Selection Sort
What is the main disadvantage of using bubble sort for large datasets?
It is difficult to implement.
It requires additional memory space.
It cannot handle duplicate values.
It has a high time complexity, making it inefficient.
You want to find the first occurrence of a specific element in a sorted array. Which search algorithm is the most efficient?
Binary Search
It depends on the size of the array.
Both are equally efficient in this case.
Linear Search
How can you efficiently delete a specific element from the middle of a sorted array while maintaining the sorted order?
By shifting all the elements after the deleted element one position back.
By swapping the element with the last element and then removing it.
Deletion in a sorted array always disrupts the order.
By directly removing the element and leaving the space empty.
What is the time complexity of finding the maximum element in a sorted array?
O(n log n)
O(n)
O(log n)
What is the primary advantage of using binary search over linear search?
Binary search works on unsorted arrays.
Binary search is generally faster for large arrays.
Binary search uses less memory.
Binary search is simpler to implement.
Which sorting algorithm works by repeatedly selecting the minimum element and placing it in its correct position?
Quick Sort
You are given a 2D array representing a matrix. What does transposing this matrix mean?
Sorting the matrix in ascending order.
Swapping rows and columns of the matrix.
Reversing all elements in the matrix.
Finding the sum of all elements in the matrix.
What is a key difference between a 1D array and a 2D array?
1D arrays store numbers while 2D arrays store characters.
1D arrays can only be accessed sequentially, 2D arrays allow random access.
1D arrays are static in size, 2D arrays can change size dynamically.
1D arrays represent linear sequences, 2D arrays represent tabular data.