Data Structures and Algorithms in Lua
Lua has one data structure, the table, so every structure on this path is one you make from it: a stack from its array part, a queue with two indices, a tree from tables that point at tables. This path has you build each one in Lua, then sort, recurse and search graphs with them, and finish on graded interview problems. Free, in your browser, with a certificate on most courses.
377 lessons228 challenges702 quiz questions
- Beginner friendly
AI-assisted coding help
Hands-on interactive lessons
Audio narration on every lesson
Quizzes to test your knowledge
23 free certificates along the path
DSA in Lua, step by step
Each step is a set of existing Coddy courses, and every Start button opens them in Lua. The three courses not taught in Lua yet are listed after the steps.
- 1Step 15 courses, in order
- 2Step 2
Data Structures Series, part two
Start this stepStartDoubly linked list, heaps and priority queues, tries, graphs and the self-balancing AVL tree. In Lua a trie node is simply a table keyed by the next character, and a graph a table of neighbor lists, so each structure is only as complicated as its idea.Start5 courses, in order- Doubly Linked List - Data Structures Series #614 lessons6 challenges
- Heaps & Priority Queues - Data Structures Series #714 lessons6 challenges
- Tries - Data Structures Series #814 lessons12 challenges
- Graphs - Data Structures Series #914 lessons12 challenges
- AVL Tree - Data Structures Series #1016 lessons6 challenges
- 3Step 3
Sorting algorithms
Start this stepStartBubble, selection, insertion, merge, quick, heap, counting and radix sort, written in Lua and watched in the visualizer.table.sortis not stable, as the Lua reference manual states; after this step you know why a sort gives stability up, and how a tie-breaking index gets it back.Start8 courses, in order- Bubble Sort11 lessons10 challenges
- Selection Sort - DSA Series9 lessons3 challenges54 questions
- Insertion Sort - DSA Series9 lessons3 challenges
- Merge Sort - DSA Series9 lessons3 challenges52 questions
- Quick Sort - DSA Series9 lessons3 challenges52 questions
- Heap Sort - DSA Series9 lessons3 challenges54 questions
- Counting Sort - DSA Series9 lessons3 challenges52 questions
- Radix Sort - DSA Series9 lessons3 challenges55 questions
- 4Step 4
Recursive thinkingDedicated page
Start this stepStartRecursion challenges in Lua, which has proper tail calls: in a call in tail position,return f(x), the called function reuses the caller's stack entry, so a tail-recursive loop never grows the stack. Ordinary deep recursion still ends in a stack overflow. Dynamic programming and bit manipulation are listed after the steps, since they are taught in Python and C++.StartDedicated page - 5Step 5
Graph algorithms
Start this stepStartBreadth-first and depth-first search, Dijkstra, Bellman-Ford, topological sort, Kruskal and Prim in Lua, on the graph you built in step two. Lua has no priority queue, so the heap from step two is the one Dijkstra needs, and breadth-first search needs a queue that never callstable.remove(t, 1).Start7 courses, in order- Breadth-First Search - Graph Algorithms9 lessons3 challenges54 questions
- Depth-First Search - Graph Algorithms9 lessons3 challenges54 questions
- Dijkstra's Algorithm - Graph Algorithms9 lessons3 challenges54 questions
- Bellman-Ford Algorithm - Graph Algorithms9 lessons3 challenges54 questions
- Topological Sort - Graph Algorithms9 lessons3 challenges55 questions
- Kruskal's Algorithm - Graph Algorithms9 lessons3 challenges57 questions
- Prim's Algorithm - Graph Algorithms9 lessons3 challenges55 questions
- 6Step 6
Interview practice
Start this stepStartTen interview challenge packs and two coding-problem banks in Lua, graded by test cases: unfamiliar problems, solved without a tutorial, with tables shaped into whatever each problem needs.Start12 courses, in order- Interview Coding Challenges - Pack I3 lessons3 challenges
- Interview Coding Challenges - Pack II3 lessons3 challenges
- Interview Coding Challenges - Pack III3 lessons3 challenges
- Interview Coding Challenges - Pack IV3 lessons3 challenges
- Interview Coding Challenges - Pack V3 lessons3 challenges
- Interview Coding Challenges - Pack VI3 lessons3 challenges
- Interview Coding Challenges - Pack VII3 lessons3 challenges
- Interview Coding Challenges - Pack VIII3 lessons3 challenges
- Interview Coding Challenges - Pack IX3 lessons3 challenges
- Interview Coding Challenges - X3 lessons3 challenges
- Coding Problems32 lessons31 challenges
- Coding Problems: Volume 225 lessons24 challenges
Learn by Doing
Write real code, query databases, build websites, and master AI prompts. Our interactive lessons cover every skill modern developers need.
Build Your Coding Streak
Stay consistent and watch your progress grow! Track your daily coding habit, protect your streak with freeze days, and earn rewards for showing up every day.
12 days streak
Return tomorrow to keep your streak!
January 2026
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
21
22
23
24
25
26
27
28
29
30
Double or Nothing
Day 5 of 7
Streak Freeze
2 left
Code Anywhere, Anytime
Take your coding journey on the go! No setup, no downloads - just open and start coding. Available on iOS, Android and Web with 4.9 star ratings.
You're Not Alone in This
Compete on global leaderboards, invite friends to earn rewards, and celebrate each other's wins. Coding is better with friends!
Every way to learn
Read, listen, test yourself, ask the AI, or look up anything you've already covered. Every lesson meets you where you are.
A variable is a named container that stores a value you can reference later in your program.
In Python, you create one by writing the name, an equals sign, then the value you want to store.
The value can change over time - reassigning the name simply points it to a new value.
Prove Your Skills
Earn certificates for every course you complete. Add them to your LinkedIn profile and resume to showcase your coding expertise to employers.
Why learn DSA in Lua on Coddy
- One structure, every structure. A Lua table is an array part and a hash part in one, and nothing else is built in: no list type, set, queue or heap. In Lua every structure is tables pointing at tables, which is the clearest view you will get of what a linked list or a tree really is.
- For Roblox, games and plugins. Lua runs Roblox (as Luau), game scripting, Neovim configuration and Redis scripts, and game code is data-structure code: an inventory is a hash table, a turn order a queue, pathfinding a graph search. Learning the structures in Lua means learning them in the language you already script in.
- Nearly the whole path in Lua. Every data structure, sort, graph algorithm, recursion challenge and interview pack is taught in Lua. Three are taught elsewhere and listed after the steps with a link to each: dynamic programming and the Python interview series in Python, and bit manipulation in C++. Everything that stays in Lua is made of tables, from the first stack to the last interview problem.
- Graded like an interview. Every lesson ends in a Lua challenge checked by test cases, and when one fails, Bugsy reads your code and nudges you toward the fix without handing over the answer. A free certificate on most courses, each verifiable at its own URL.
Frequently asked questions about DSA in Lua
Is Lua good for data structures and algorithms?
nil instead of an error, and the length operator #t is only reliable on a sequence without nil holes. Few interviews are held in Lua, so if one is your goal, the interview packs are also offered in the language you will use there.How do you build a stack and a queue from a Lua table?
table.insert(t, x) pushes and table.remove(t) pops. A queue needs more care, because table.remove(t, 1) shifts every remaining element down one place, so each dequeue is O(n). Keep two indices instead, first and last: add at last + 1, read at first, set that slot to nil and advance, and dequeueing becomes constant time. Step one has you build both.Why does #t sometimes give the wrong length in Lua?
#t sometimes give the wrong length in Lua?# returns a border of the table: an index n where t[n] is not nil and t[n + 1] is. A proper sequence has exactly one border, its length; put a nil in the middle and there can be several, and # may return any of them. So never store nil in an array you measure with #, and in structures with gaps, such as a queue with two indices, track the size yourself.Do data structures matter for Roblox scripting?
# operator, so what you build here carries straight over.Which courses on this path are not taught in Lua?
&, |, << and >> and writes both XOR and NOT as ~.