Westonci.ca is the best place to get answers to your questions, provided by a community of experienced and knowledgeable experts. Join our Q&A platform to get precise answers from experts in diverse fields and enhance your understanding. Join our platform to connect with experts ready to provide precise answers to your questions in different areas.

Which of the basic data structures is the most suitable if you want to be able to insert elements in the middle in O(1)?
A. Array
B. Queue
C. Linked list
D. Stack


Sagot :

Answer:

A. Array

Explanation:

An array is a data structure that holds a collection of similar data types. Though it is ordered, the location of the array is indexed, which means that the items of the array can be accessed and retrieved with their index location values (starting from 0 to n).

The time complexity of accessing or retrieving a specific item in an array is O(1) which is a constant of the specified item.