Brainlag
  1. C
  2. Advanced
26/38 lessons

Linked lists

55 min6 exercisesPremium

Build a singly linked list in C from heap nodes and next pointers: walk it, push at both ends, remove a node, reverse it and free it without leaks.

The skill
Build and change a linked list of heap nodes, including the head, without losing or leaking a node.
You make
A track list with totals, push at both ends, removal, in-place reversal and a top-five leaderboard.

Premium lesson

£7.99 a month or £59 a year. Cancel any time.

Builds on 25 Debugging C on purpose. Free to try: C Foundations and the playground.

Step 1 of 10
exercise_1.c

You've reached the good stuff.

6 exercises in this lesson, checked as you type. Premium opens every lesson after Foundations, in all four courses.

C, 32-bit: int and pointers are 4 bytes