You are given a 2D array representing a matrix. What does transposing this matrix mean?
Reversing all elements in the matrix.
Sorting the matrix in ascending order.
Swapping rows and columns of the matrix.
Finding the sum of all elements in the matrix.
If you have an array of size 5 and you try to add a 6th element to it, what is a likely outcome?
The array will automatically resize to accommodate the new element.
The new element will overwrite the value at the first index (index 0).
An error or exception will occur indicating an out-of-bounds access.
The behavior is undefined and can lead to unpredictable program crashes.
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 store the value of the first element in the array.
To indicate the data type of elements stored in the array.
Accessing an element outside the valid index range of an array leads to what kind of error?
ValueError
TypeError
SyntaxError
IndexError or OutOfBounds exception
What is the time complexity of finding the length of an array in most programming languages?
O(n^2) - Quadratic Time
O(n) - Linear Time
O(log n) - Logarithmic Time
O(1) - Constant Time
What is the space complexity of storing a 2D array with 'm' rows and 'n' columns?
O(1)
O(m)
O(n)
O(m * n)
Which of the following is a valid array declaration in a common programming language (syntax may vary slightly)?
int numbers[] = {1, 2, 3, 4};
numbers = array(1, 2, 3, 4);
array numbers = [1, 2, 3, 4];
All of the above.
What is a key difference between a 1D array and a 2D array?
1D arrays store numbers while 2D arrays store characters.
1D arrays are static in size, 2D arrays can change size dynamically.
1D arrays represent linear sequences, 2D arrays represent tabular data.
1D arrays can only be accessed sequentially, 2D arrays allow random access.
You want to find the first occurrence of a specific element in a sorted array. Which search algorithm is the most efficient?
Both are equally efficient in this case.
It depends on the size of the array.
Linear Search
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.
Inserting an element at the beginning.
Finding the length of the array.