Linked Lists & the Linked Playlist
In short: a Python list is an array — items sit side by side in one
block, which is why tracks[i] is O(1) but inserting near the front means
shifting everything after it: O(n). A linked list gives up the block.
Each track lives in its own node, holding the value and a reference to
the next node; the list itself is just a reference to the first node, the
head. No index, only arrows — so reaching node i costs O(n) hops, but
once you hold a node, splicing one in or out next to it is O(1): change
one or two arrows, shift nothing.

Splice a track into a 5,000-track party mix
A node holds a value and a next reference. Building a chain by always
putting the new node in front of the head is fast, but reverses the order:
class Node:
def __init__(self, val, next=None):
self.val = val
self.next = next
head = None
for title in ["A", "B", "C"]:
head = Node(title, head)
print(head.val)With no index, the only way through is walking the arrows — O(n), where a list's index was O(1):
Once you hold a node, inserting after it changes one or two arrows — nothing shifts. The mistake: overwriting the old arrow before the new node has taken a copy of it:
This should splice Bridge in after Intro and print all four tracks. It prints Bridge over and over instead.
❓ Cross-question — "O(1)? You still had to find Intro first." True — that walk is O(n). The splice itself is O(1) only when you already hold the node, which a player usually does: it holds the node that's playing, so "play this next" needs no walk.