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.
Binary Search
Linear Search
What is the time complexity of accessing an element in a 2D array with 'm' rows and 'n' columns?
O(1)
O(m * n)
O(log m + log n)
O(m + n)
What is the purpose of having a base address associated with an array in memory?
To store the length of the array.
To indicate the data type of elements stored in the array.
To identify the starting memory location where the array is stored.
To store the value of the first element in the array.
How is an element at row 'i' and column 'j' typically accessed in a 2D array named 'matrix'?
matrix(i)[j]
matrix.get(i, j)
matrix[i][j]
matrix[i, j]
What is the main disadvantage of using bubble sort for large datasets?
It cannot handle duplicate values.
It has a high time complexity, making it inefficient.
It requires additional memory space.
It is difficult to implement.
How can you efficiently delete a specific element from the middle of a sorted array while maintaining the sorted order?
By swapping the element with the last element and then removing it.
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.
Accessing an element outside the valid index range of an array leads to what kind of error?
SyntaxError
ValueError
IndexError or OutOfBounds exception
TypeError
Which operation is typically NOT efficient on a standard array?
Finding the length of the array.
Updating an element at a given index.
Retrieving the value at a given index.
Inserting an element at the beginning.
If you have an array of size 5 and you try to add a 6th element to it, what is a likely outcome?
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 array will automatically resize to accommodate the new element.
The behavior is undefined and can lead to unpredictable program crashes.
In an array with indices starting at 0, what is the index of the last element in an array of size 'n'?
n - 1
It depends on the data type of the array.
0
n