+1 vote
in Data Structures & Algorithms I by (110k points)
What is the time complexity for inserting/deleting at the beginning of the array?

(a) O(1)

(b) O(n)

(c) O(logn)

(d) O(nlogn)

Question is from Dynamic Array in section Arrays Types of Data Structures & Algorithms I

I had been asked this question in quiz.

1 Answer

+1 vote
by (408k points)
selected by
Best answer
Correct option is (b) O(n)

Easiest explanation - All the other elements will have to be moved, hence O(n).

Related questions

Welcome to TalkJarvis QnA, a question-answer community website for the people by the people. On TalkJarvis QnA you can ask your doubts, curiosity, questions and whatever going in your mind either related to studies or others. Experts and people from different fields will answer.