What is the time complexity of finding the maximum element in a sorted array?
O(n log n)
O(n)
O(1)
O(log n)
Which operation is typically NOT efficient on a standard array?
Inserting an element at the beginning.
Retrieving the value at a given index.
Updating an element at a given index.
Finding the length of the array.
You are given a 2D array representing a matrix. What does transposing this matrix mean?
Finding the sum of all elements in the matrix.
Swapping rows and columns of the matrix.
Reversing all elements in the matrix.
Sorting the matrix in ascending order.
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.
Deletion in a sorted array always disrupts the 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.
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?
Binary Search
Depth First Search (DFS)
Quick Sort
Bubble Sort
What is the primary advantage of using binary search over linear search?
Binary search uses less memory.
Binary search works on unsorted arrays.
Binary search is generally faster for large arrays.
Binary search is simpler to implement.
You need to search for an element in an array where elements are randomly placed. Which search algorithm is your only option?
Linear Search
None of the above.
Both can be used effectively.
In an array with indices starting at 0, what is the index of the last element in an array of size 'n'?
n - 1
0
It depends on the data type of the array.
n
What is the purpose of having a base address associated with an array in memory?
To store the length of the array.
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.
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 are static in size, 2D arrays can change size dynamically.
1D arrays can only be accessed sequentially, 2D arrays allow random access.
1D arrays store numbers while 2D arrays store characters.