luaguides

Tutorial series

Lua Data Structures

6 tutorials — follow in order for the best learning path.

  1. Stacks and Queues in Lua

    Implement stacks and queues in Lua using tables. Learn push/pop, the O(n) trap with table.remove(t, 1), and how to build an efficient circular buffer.

  2. Implementing Sets in Lua

    Learn how to implement and use sets in Lua using tables with true sentinel values, including set operations, iteration gotchas, and read-only proxies.

  3. Singly and Doubly Linked Lists in Lua

    Learn how to implement singly and doubly linked lists in Lua using tables, with performance comparisons and practical examples.

  4. Binary Trees and BSTs in Lua

    Learn how to implement binary trees and binary search trees in Lua with clear explanations and runnable code examples.

  5. Priority Queues and Heaps in Lua

    Learn how to implement priority queues and binary heaps in Lua using tables, with practical examples for task scheduling and event queues.

  6. Graph Representations in Lua

    Learn the two main ways to represent graphs in Lua: adjacency matrices and adjacency lists, with BFS and DFS implementations.