arr = [10, 20, 30, 40, 50] arr[2] = 35 arr.append(60) print(arr)
The code changes the element at index 2 from 30 to 35, then adds 60 at the end. So the final list is [10, 20, 35, 40, 50, 60].
Arrays provide fast access by index because elements are stored next to each other in memory. Insertions/deletions in the middle are slow, and key-value storage is better with dictionaries.
The list has indices 0, 1, 2. Trying to assign to index 3 causes an IndexError because it is out of range.
Linked lists allow insertions and deletions anywhere efficiently because they use pointers to link nodes, avoiding shifting elements like arrays.
Linked lists store extra pointers for each element to link nodes, which adds memory overhead. Arrays store elements one after another without extra pointers, making them more memory efficient.