Which operation is typically NOT efficient on a standard array?
Inserting an element at the beginning.
Updating an element at a given index.
Finding the length of the array.
Retrieving the value at a given index.
You need to search for an element in an array where elements are randomly placed. Which search algorithm is your only option?
Linear Search
Both can be used effectively.
Binary Search
None of the above.
What is the space complexity of storing a 2D array with 'm' rows and 'n' columns?
O(m * n)
O(m)
O(n)
O(1)
You are given a 2D array representing a matrix. What does transposing this matrix mean?
Sorting the matrix in ascending order.
Reversing all elements in the matrix.
Finding the sum of all elements in the matrix.
Swapping rows and columns of the matrix.
Which sorting algorithm works by repeatedly selecting the minimum element and placing it in its correct position?
Merge Sort
Selection Sort
Bubble Sort
Quick Sort
What is the time complexity of accessing an element in a 2D array with 'm' rows and 'n' columns?
O(m + n)
O(log m + log n)
Consider a 2D array storing characters to represent a word search grid. You want to check if a given word exists in the grid horizontally or vertically. Which algorithm would be suitable for this task?
Depth First Search (DFS)
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?
Swapping rows is not possible in a 2D array.
Iterate through columns, swapping elements at 'image[r1][j]' and 'image[r2][j]' for each column 'j'.
Directly assign 'image[r1]' to 'image[r2]' and vice-versa.
Create a new 2D array with the swapped rows.
What is the purpose of having a base address associated with an array in memory?
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.
To store the value of the first element in the array.
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[i][j]
matrix.get(i, j)