What is the time complexity of finding the maximum element in a sorted array?
O(n log n)
O(log n)
O(n)
O(1)
Given an array of integers, how can you efficiently count the occurrences of a specific element?
Iterate through the array and increment a counter for each occurrence.
All of the above methods are equally efficient.
Sort the array and use binary search.
Use a hash map to store the frequency of each element.
You are given a 2D array representing a matrix. What does transposing this matrix mean?
Swapping rows and columns of the matrix.
Sorting the matrix in ascending order.
Reversing all elements in the matrix.
Finding the sum of all elements in the matrix.
What is the main disadvantage of using bubble sort for large datasets?
It has a high time complexity, making it inefficient.
It requires additional memory space.
It cannot handle duplicate values.
It is difficult to implement.
Which of the following is a valid array declaration in a common programming language (syntax may vary slightly)?
array numbers = [1, 2, 3, 4];
numbers = array(1, 2, 3, 4);
All of the above.
int numbers[] = {1, 2, 3, 4};
Accessing an element outside the valid index range of an array leads to what kind of error?
IndexError or OutOfBounds exception
TypeError
ValueError
SyntaxError
What is the purpose of having a base address associated with an array in memory?
To identify the starting memory location where the array is stored.
To store the length of the array.
To indicate the data type of elements stored in the array.
To store the value of the first element in the array.
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.
Binary Search
How is an element at row 'i' and column 'j' typically accessed in a 2D array named 'matrix'?
matrix.get(i, j)
matrix[i, j]
matrix(i)[j]
matrix[i][j]
You want to find the first occurrence of a specific element in a sorted array. Which search algorithm is the most efficient?
It depends on the size of the array.
Both are equally efficient in this case.