Suppose that you need to maintain a collection of data whose contents are fixed- i.e., you need to search for and retrieve existing items, but never need to add or delete items. Although the collection of data may be quite large, you may assume that it can fit in the computer's memory. Which of the following data structures is the most efficient one to use for this task?

a. a sorted array
b. a linked list
c. a binary search tree
d. a queue
e. they are all the same

Respuesta :

Answer:

Option a: a sorted array

Explanation:

Since the expectation on the data structure never need to add or delete items, a sorted array is the most desirable option. An array is known for its difficulty to modify the size (either by adding item or removing item). However, this disadvantage would no longer be a concern for this task. This is also the reason, linked list, binary search tree and queue is not a better option here although they offer much greater efficiency to add and remove item from collection.

On another hand,  any existing items from the sorted array can be easily retrieved using address indexing and therefore the data query process can be very fast and efficient.

ACCESS MORE