Kodewick
Start learning →
Data structures and algorithms · C

Data Structures and Algorithms in C

Build data structures for real in C: nodes, pointers, malloc and free, every step drawn for you, then write it yourself, run it and get it checked. Each chapter ends with the patterns interviews and exams ask for.

Start with lesson 1 →50 lessons · about 14 hours · free · runs in your browser
  1. Part 1Getting started: how fastCounting steps, Big O, and where log n comes from.3 lessons · 0.5 h
    1. Lesson 1Counting the steps14 minStart
    2. Lesson 2Big O: O(1), O(n), O(n²)15 minStart
    3. Lesson 3Where log n comes from14 minStart
  2. Part 2Arrays and linked listsArrays by index, inserting and deleting, growing with realloc; linked list nodes, pointers, inserting and deleting, dummy head nodes, doubly linked and circular lists.7 lessons · 1.5 h
    1. Lesson 4Arrays: straight to any index12 minStart
    2. Lesson 5Inserting and deleting in an array15 minStart
    3. Lesson 6Arrays that grow: realloc14 minStart
    4. Lesson 7Linked lists: nodes and pointers14 minStart
    5. Lesson 8Inserting and deleting in a linked list15 minStart
    6. Lesson 9Doubly linked and circular lists14 minStart
    7. Lesson 10Patterns: arrays or linked lists18 minStart
  3. Part 3Stacks and queuesArray and linked stacks, matching brackets, evaluating and converting postfix expressions, queues and circular queues (full or empty?), and the monotonic stack.5 lessons · 1.5 h
    1. Lesson 11Stacks: last in, first out14 minStart
    2. Lesson 12Matching brackets12 minStart
    3. Lesson 13Evaluating expressions: postfix15 minStart
    4. Lesson 14Queues and circular queues15 minStart
    5. Lesson 15Patterns: stacks and queues20 minStart
  4. Part 4Hash tablesDesigning hash functions, handling collisions with open addressing and with chaining, load factors and resizing, and questions like collision counts and two sum.4 lessons · 1 h
    1. Lesson 16Hash functions18 minStart
    2. Lesson 17Open addressing17 minStart
    3. Lesson 18Separate chaining16 minStart
    4. Lesson 19Patterns: hash tables19 minStart
  5. Part 5TreesBinary trees and recursion, the four traversals, drawing a tree from its traversals, binary search trees, heaps and priority queues, heap sort and top k, Huffman trees: every step drawn on the tree.8 lessons · 2 h
    1. Lesson 20Binary trees and recursion15 minStart
    2. Lesson 21The four traversals of a binary tree16 minStart
    3. Lesson 22Drawing a binary tree from its traversals15 minStart
    4. Lesson 23Binary search trees17 minStart
    5. Lesson 24Heaps and priority queues17 minStart
    6. Lesson 25Heap sort and top k17 minStart
    7. Lesson 26Huffman trees and Huffman codes15 minStart
    8. Lesson 27Patterns: trees18 minStart
  6. Part 6GraphsAdjacency matrices and lists, BFS and DFS, topological sort, Dijkstra's shortest paths, Prim's and Kruskal's minimum spanning trees (union-find), every step drawn on the graph.7 lessons · 2 h
    1. Lesson 28Storing graphs: adjacency matrices and lists16 minStart
    2. Lesson 29Breadth-first search17 minStart
    3. Lesson 30Depth-first search17 minStart
    4. Lesson 31Topological sort15 minStart
    5. Lesson 32Shortest paths: Dijkstra18 minStart
    6. Lesson 33Minimum spanning trees: Prim and Kruskal18 minStart
    7. Lesson 34Patterns: graphs18 minStart
  7. Part 7SearchingSequential and binary search, binary search boundaries and searching for the answer, balanced trees (AVL rotations) and B-trees, and binary search decision trees and average search length.4 lessons · 1.5 h
    1. Lesson 35Sequential search and binary search15 minStart
    2. Lesson 36Binary search boundaries16 minStart
    3. Lesson 37Balanced trees and B-trees22 minStart
    4. Lesson 38Patterns: searching22 minStart
  8. Part 8SortingBubble, selection, insertion, Shell, merge, quick, counting and radix sort: each one watched as it really runs, comparisons and swaps counted, then compared on stability and complexity.6 lessons · 2 h
    1. Lesson 39Bubble sort and selection sort20 minStart
    2. Lesson 40Insertion sort and Shell sort20 minStart
    3. Lesson 41Merge sort22 minStart
    4. Lesson 42Quicksort18 minStart
    5. Lesson 43Counting sort and radix sort15 minStart
    6. Lesson 44Patterns: sorting18 minStart
  9. Part 9Algorithm designRecursion and divide and conquer, backtracking, greedy algorithms, dynamic programming and the knapsack problem: recursion trees, backtracking trees and DP tables drawn box by box.6 lessons · 2 h
    1. Lesson 45Recursion and divide and conquer18 minStart
    2. Lesson 46Backtracking18 minStart
    3. Lesson 47Greedy algorithms16 minStart
    4. Lesson 48Dynamic programming17 minStart
    5. Lesson 49The knapsack problem18 minStart
    6. Lesson 50Patterns: algorithm design20 minStart

Questions

Is it really free?

Yes. Every lesson, example and exercise is free, with no sign-up.

Do I need to know C first?

A little: variables, loops, functions, structs, and what a pointer is. If not, start with our C course; the pointer lessons matter most.

Is there a Python edition?

Yes: Data Structures and Algorithms in Python, the same chapters taught the Python way (/en/learn/dsa-py/).

Is there a C++ edition?

Yes: Data Structures and Algorithms in C++, where each structure is written by hand first, then with the STL (/en/learn/dsa-cpp/).

Where is my progress kept?

In this browser, with no account.