Skip to content
Code ReadingAppend at the End
Read the Big-O

Append at the End

For every new value it walks from the head to the tail. How long does building a chain of n values take?
1def build(values):
2 head = None
3 for v in values:
4 node = Node(v)
5 if head is None:
6 head = node
7 else:
8 cur = head
9 while cur.next:
10 cur = cur.next
11 cur.next = node
12 return head