Q8) i am not able to understand how the answer of that question is O(n)

As on average it should be O(1) and when it reaches 1000 then it will take O(n) time complexity to make the capacity double and then it will be again O(1) .so on average it should be O(1).

please give me some time i`ll let u know about the correct logic

reason why its complexity is O( N ) is
kyunki agr capacity full hogyi to wapis copy wgarah krna hoga.

but on average the time complexity will be O(1) AND for a single case it will be O(n) that is when my current size reaches the capacity that is 1000 and then for that case the time complexity will be O(n) and then it will be again O(1).

the avg becomes O ( N )

the worst time complexity is calculated by the peak time which comes while performing the operation

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.