Question:

What is the time complexity to insert an element at the beginning of a dynamic array?

Show Hint

Inserting an element at the beginning of an array requires shifting all the elements, which results in O(n) time complexity.
Updated On: Jun 16, 2025
  • O(1)
  • O(n)
  • O(nlogn)
  • O(logn)
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is B

Solution and Explanation

In a dynamic array, when an element is inserted at the beginning, all the existing elements have to be shifted one position to the right. Hence, the time complexity for this operation is O(n).
Was this answer helpful?
0
0