Given an array of integers, how can you efficiently count the occurrences of a specific element?
All of the above methods are equally efficient.
Iterate through the array and increment a counter for each occurrence.
Use a hash map to store the frequency of each element.
Sort the array and use binary search.
Which operation is typically NOT efficient on a standard array?
Updating an element at a given index.
Retrieving the value at a given index.
Finding the length of the array.
Inserting an element at the beginning.
What is the time complexity of finding the maximum element in a sorted array?
O(n log n)
O(1)
O(log n)
O(n)
Accessing an element outside the valid index range of an array leads to what kind of error?
IndexError or OutOfBounds exception
ValueError
TypeError
SyntaxError
What is the primary advantage of using binary search over linear search?
Binary search is simpler to implement.
Binary search uses less memory.
Binary search works on unsorted arrays.
Binary search is generally faster for large arrays.
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)
What is the space complexity of storing a 2D array with 'm' rows and 'n' columns?
O(m)
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 value of the first element in the array.
To identify the starting memory location where the array is stored.
To store the length of the array.
Which of the following sorting algorithms has the best average-case time complexity?
Insertion Sort
Merge Sort
Selection Sort
Bubble Sort
Which of the following is a valid array declaration in a common programming language (syntax may vary slightly)?
All of the above.
int numbers[] = {1, 2, 3, 4};
numbers = array(1, 2, 3, 4);
array numbers = [1, 2, 3, 4];