Problem Statement
Which of the following data structures are indexed structures?
Explanation
Linear arrays are indexed structures because elements can be accessed directly using their index position. Array indexing provides constant time O of 1 access to any element.
Queues do not support direct indexing as elements can only be accessed from the front. Trees use hierarchical relationships rather than indices. The ability to access elements by index makes arrays very efficient for random access operations.
Code Solution
SolutionRead Only
// Array with direct index access - O(1)
int arr[] = {10, 20, 30, 40, 50};
int element = arr[2]; // Direct access to index 2, returns 30
// Queue - no direct index access
Queue<Integer> queue = new LinkedList<>();
queue.add(10);
queue.add(20);
// Can only access front element with peek() or poll()