What is the purpose of having a base address associated with an array in memory?
To store the value of the first element in 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 length of the array.
Which of the following is a valid array declaration in a common programming language (syntax may vary slightly)?
numbers = array(1, 2, 3, 4);
int numbers[] = {1, 2, 3, 4};
All of the above.
array numbers = [1, 2, 3, 4];
How can you efficiently delete a specific element from the middle of a sorted array while maintaining the sorted order?
By shifting all the elements after the deleted element one position back.
By directly removing the element and leaving the space empty.
By swapping the element with the last element and then removing it.
Deletion in a sorted array always disrupts the order.
You want to find the first occurrence of a specific element in a sorted array. Which search algorithm is the most efficient?
Binary Search
Linear Search
Both are equally efficient in this case.
It depends on the size of the array.
Given an array of integers, how can you efficiently count the occurrences of a specific element?
Iterate through the array and increment a counter for each occurrence.
Sort the array and use binary search.
All of the above methods are equally efficient.
Use a hash map to store the frequency of each element.
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?
Depth First Search (DFS)
Bubble Sort
Quick Sort
In an array with indices starting at 0, what is the index of the last element in an array of size 'n'?
n
n - 1
It depends on the data type of the array.
0
Which of the following sorting algorithms has the best average-case time complexity?
Insertion Sort
Selection Sort
Merge Sort
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.
Finding the sum of all elements in the matrix.
Swapping rows and columns of the matrix.
What is the primary advantage of using binary search over linear search?
Binary search is generally faster for large arrays.
Binary search is simpler to implement.
Binary search uses less memory.
Binary search works on unsorted arrays.