Stage 4 · Lesson 3 of 10
Linked lists
A stores each item in its own node, together with a pointer to the next node. In a doubly linked list, each node also points to the one before. Inserting or removing a node you already hold is O(1), because nothing has to shift.
But reaching the i-th item means walking from the head (the first node), which is O(n). Nodes scattered around memory are also slow for the . In everyday code you will nearly always choose a instead.
Build a linked list anyway. Writing insert, delete and reverse makes references concrete, and linked nodes are how , queues, trees and are built. Draw boxes and arrows on paper before you write any pointer code.
A question to check yourself, an AI practice session and 1 cheat sheet entry come when you add the roadmap to your account. Add it
Resources for this stage
Start with· follow one of these
- CoursePaidGrokking Data Structures & Algorithms for Coding Interviews
Design Gurus · Beginner · Subscription
Each structure built from first principles, with solutions in Python, Java, C++, JavaScript and C#
- CourseFreeCS50: Introduction to Computer Science
Harvard University · Beginner
Free: weeks 3 and 5 cover searching, sorting, linked lists, hash tables and trees
Practise
Keep handy
Also worth your time
Time and space complexity worked through five common algorithms