Question DSA-ARR-0002
EasyWhat is the time complexity of inserting an element at the beginning of an array of n elements?
- A.
O(1)
- B.
O(n²)
- C.
Show answer and explanation
Answer: C
Every existing element must shift one place to the right.
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Arrays question
What is the time complexity of inserting an element at the beginning of an array of n elements?
O(1)
O(n²)
Answer: C
Every existing element must shift one place to the right.
O(n)
O(log n)