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.
In an array with indices starting at 0, what is the index of the last element in an array of size 'n'?
n - 1
0
It depends on the data type of the array.
n
What is the primary advantage of using binary search over linear search?
Binary search is generally faster for large arrays.
Binary search uses less memory.
Binary search works on unsorted arrays.
Binary search is simpler to implement.
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
Bubble Sort
Depth First Search (DFS)
Quick Sort
What is the time complexity of accessing an element in a 2D array with 'm' rows and 'n' columns?
O(m + n)
O(log m + log n)
O(m * n)
O(1)
You are given a 2D array representing a matrix. What does transposing this matrix mean?
Swapping rows and columns of the matrix.
Finding the sum of all elements in the matrix.
Sorting the matrix in ascending order.
Reversing all elements in the matrix.
Given an array of integers, how can you efficiently count the occurrences of a specific element?
All of the above methods are equally efficient.
Sort the array and use binary search.
Iterate through the array and increment a counter for each occurrence.
Use a hash map to store the frequency of each element.
Which sorting algorithm works by repeatedly selecting the minimum element and placing it in its correct position?
Selection Sort
Merge Sort
Which operation is typically NOT efficient on a standard array?
Retrieving the value at a given index.
Finding the length of the array.
Inserting an element at the beginning.
Updating an element at a given index.
What is the main disadvantage of using bubble sort for large datasets?
It cannot handle duplicate values.
It is difficult to implement.
It requires additional memory space.
It has a high time complexity, making it inefficient.