Welcome to Westonci.ca, the place where your questions find answers from a community of knowledgeable experts. Experience the convenience of getting accurate answers to your questions from a dedicated community of professionals. Join our Q&A platform to connect with experts dedicated to providing accurate answers to your questions in various fields.

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.