What is the main disadvantage of using bubble sort for large datasets?
It is difficult to implement.
It has a high time complexity, making it inefficient.
It cannot handle duplicate values.
It requires additional memory space.
Accessing an element outside the valid index range of an array leads to what kind of error?
ValueError
IndexError or OutOfBounds exception
TypeError
SyntaxError
What is the space complexity of storing a 2D array with 'm' rows and 'n' columns?
O(n)
O(1)
O(m)
O(m * n)
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
Quick Sort
Depth First Search (DFS)
Bubble Sort
What is a key difference between a 1D array and a 2D array?
1D arrays are static in size, 2D arrays can change size dynamically.
1D arrays store numbers while 2D arrays store characters.
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?
It depends on the size of the array.
Linear Search
Both are equally efficient in this case.
Which of the following sorting algorithms has the best average-case time complexity?
Selection Sort
Insertion Sort
Merge Sort
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 behavior is undefined and can lead to unpredictable program crashes.
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.
In an array with indices starting at 0, what is the index of the last element in an array of size 'n'?
n
It depends on the data type of the array.
n - 1
0
What is the primary advantage of using binary search over linear search?
Binary search works on unsorted arrays.
Binary search is generally faster for large arrays.
Binary search uses less memory.
Binary search is simpler to implement.