How can you efficiently delete a specific element from the middle of a sorted array while maintaining the sorted order?
By directly removing the element and leaving the space empty.
By swapping the element with the last element and then removing it.
By shifting all the elements after the deleted element one position back.
Deletion in a sorted array always disrupts the order.
What is the space complexity of storing a 2D array with 'm' rows and 'n' columns?
O(1)
O(m)
O(n)
O(m * n)
How is an element at row 'i' and column 'j' typically accessed in a 2D array named 'matrix'?
matrix(i)[j]
matrix[i][j]
matrix.get(i, j)
matrix[i, j]
Imagine a 2D array representing a grayscale image. Each element holds a pixel intensity value. How would you swap two rows 'r1' and 'r2' in this array?
Iterate through columns, swapping elements at 'image[r1][j]' and 'image[r2][j]' for each column 'j'.
Create a new 2D array with the swapped rows.
Directly assign 'image[r1]' to 'image[r2]' and vice-versa.
Swapping rows is not possible in a 2D array.
Which sorting algorithm works by repeatedly selecting the minimum element and placing it in its correct position?
Quick Sort
Bubble Sort
Selection Sort
Merge Sort
Which operation is typically NOT efficient on a standard array?
Finding the length of the array.
Retrieving the value at a given index.
Updating an element at a given index.
Inserting an element at the beginning.
You are given a 2D array representing a matrix. What does transposing this matrix mean?
Finding the sum of all elements in the matrix.
Sorting the matrix in ascending order.
Swapping rows and columns of the matrix.
Reversing all elements in the matrix.
Which of the following is a valid array declaration in a common programming language (syntax may vary slightly)?
numbers = array(1, 2, 3, 4);
All of the above.
array numbers = [1, 2, 3, 4];
int numbers[] = {1, 2, 3, 4};
What is the purpose of having a base address associated with an array in memory?
To store the value of the first element in the array.
To indicate the data type of elements stored in the array.
To store the length of the array.
To identify the starting memory location where the array is stored.
What is the main disadvantage of using bubble sort for large datasets?
It cannot handle duplicate values.
It requires additional memory space.
It has a high time complexity, making it inefficient.
It is difficult to implement.