233k views
2 votes
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

1 Answer

5 votes

Answer:

A. Array

Step-by-step 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.

User Tshepang
by
4.2k points