Suppose a list of five element are there . a = [1,2,4,5,6] . and i want to insert element 3 in between , so what will happen if i use insert func of python .
- A separate memory allocated for element 3 only and its reference is attached to existing
- A new memory will be allocated to (aproxx 1.3 times of previous memory) whole list and element 3 attached to it
- List item
If option 1 , then why time comp for insert() func is o(n) in python , not o(1)