You need to search for an element in an array where elements are randomly placed. Which search algorithm is your only option?
Binary Search
Both can be used effectively.
None of the above.
Linear Search
What is the time complexity of accessing an element in a 2D array with 'm' rows and 'n' columns?
O(log m + log n)
O(m * n)
O(m + n)
O(1)
How can you efficiently delete a specific element from the middle of a sorted array while maintaining the sorted order?
Deletion in a sorted array always disrupts the 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.
What is the time complexity of finding the maximum element in a sorted array?
O(log n)
O(n)
O(n 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?
Quick Sort
Bubble Sort
Depth First Search (DFS)
What is a key difference between a 1D array and a 2D array?
1D arrays represent linear sequences, 2D arrays represent tabular data.
1D arrays can only be accessed sequentially, 2D arrays allow random access.
1D arrays store numbers while 2D arrays store characters.
1D arrays are static in size, 2D arrays can change size dynamically.
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 identify the starting memory location where the array is stored.
To indicate the data type of elements stored in the array.
To store the length of the array.
Which code snippet correctly initializes a 2D array named 'grid' with 3 rows and 4 columns, all filled with zeros?
int grid[3][4] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int grid[3][4] = {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}};
int grid[3][4] = {0};
int grid[3][4]; for (int i = 0; i < 3; i++) for (int j = 0; j < 4; j++) grid[i][j] = 0;
Which operation is typically NOT efficient on a standard array?
Inserting an element at the beginning.
Finding the length of the array.
Retrieving the value at a given index.
Updating an element at a given index.
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.
Finding the sum of all elements in the matrix.
Reversing all elements in the matrix.