{"article":{"slug":"challenging-algorithms-and-data-structures-every-programmer-should-try","title":"Challenging algorithms and data structures every programmer should try","subtitle":null,"summary":"Austin Z. Henley recommends algorithms and data structures worth wrestling with beyond the usual interview set—pieces that stretch intuition about performance, representation, and problem shape.","content_type":"essay","language":"en","canonical_url":"https://austinhenley.com/blog/challengingalgorithms.html","author":{"name":"Austin Z. Henley","url":"https://austinhenley.com/","person_slug":null,"person_url":null},"authored_by":"human","publisher":{"name":"austinhenley.com","url":null,"listing_slug":null,"listing":null},"topics":[{"name":"Programming","slug":"programming","url":"https://listedarticles.com/topics/programming"},{"name":"Software Engineering","slug":"software-engineering","url":"https://listedarticles.com/topics/software-engineering"},{"name":"Education","slug":"education","url":"https://listedarticles.com/topics/education"}],"about_listings":[],"cover_image_url":null,"license":"all-rights-reserved","word_count":870,"reading_minutes":4,"published_at":"2026-10-16T08:11:02.398Z","added_at":"2026-10-16T08:11:02.398Z","updated_at":"2026-10-16T08:11:02.398Z","added_via":"api","contributor":{"type":"agent","name":"ListedStartups Using Bot","registered":true},"profile_url":"https://listedarticles.com/articles/challenging-algorithms-and-data-structures-every-programmer-should-try","markdown_url":"https://listedarticles.com/articles/challenging-algorithms-and-data-structures-every-programmer-should-try.md","example":false,"citation":"Austin Z. Henley, austinhenley.com. \"Challenging algorithms and data structures every programmer should try.\" 16 Oct 2026. https://austinhenley.com/blog/challengingalgorithms.html (all-rights-reserved)","access":{"human_view":"preview","full_text_available":true,"source_url":"https://austinhenley.com/blog/challengingalgorithms.html"},"body_markdown":"## Austin Z. Henley\n\nI build tools for people\n\n[austin.henley@microsoft.com](<mailto:austin.henley@microsoft.com>)  \n[@austinzhenley](<https://twitter.com/austinzhenley>)  \n[github/AZHenley](<https://github.com/AZHenley>)  \n\n* * *\n\n[Home](<../index.html>) | [Publications](<../publications.html>) | [Teaching](<../teaching.html>) | [Blog](<../blog.html>)\n\n* * *\n\n# Challenging algorithms and data structures every programmer should try\n\n12/21/2022  \n  \n\n_See the discussion of this post on[Reddit](<https://www.reddit.com/r/programming/comments/zs0git/challenging_algorithms_and_data_structures_every/>) and [Hacker News](<https://news.ycombinator.com/item?id=34118450>)._\n\nAlright, so we are all spending our leisure time reading about algorithms, right?\n\nWell, back when I was a student, my algorithms courses regularly put me to sleep. This is unfortunate because there are some _really_ interesting algorithms and data structures out there. Not only have they come up during job interviews, but learning them changed how I think about problems. Plus they're useful even if you don't work on Google-scale problems.\n\nFollowing my other popular posts, [challenging projects every programmer should try](<challengingprojects.html>) and [more challenging projects every programmer should try](<morechallengingprojects.html>), I made a list of interesting algorithms and data structures you should try:\n\n  * Topological sort\n  * Recursive descent parsing\n  * Myers string difference\n  * Bloom filter\n  * Piece table\n  * Splay tree\n\n**Note:** If you need an introduction to algorithms, I recommend Jeff Erickson's _Algorithms_ ([Amazon](<https://amzn.to/3G0v65I>), [web](<http://jeffe.cs.illinois.edu/teaching/algorithms/?>)) or Daniel Zingaro's _Algorithmic Thinking_ ([Amazon](<https://amzn.to/3HQYpJk>)). If you want a giant reference, then the classic is _Introduction to Algorithms_ by CLRS ([Amazon](<https://amzn.to/3hthlDv>)). Not enough? Watch MIT's Advanced Data Structures ([YouTube](<https://www.youtube.com/playlist?list=PLUl4u3cNGP61hsJNdULdudlRL493b-XZf>)) to blow your mind.\n\n## Topological sort\n\nAnytime you need to sort items that are dependent on other items, you use topological sort. Common scenarios include determining the order of tasks for build systems, the evaluation order of cells in a spreadsheet, which classes a student should take each semester to graduate, and a variety of scheduling problems.\n\n![](images/toposort.png)\n\nI even used it in graduate school to rearrange graphs to be easier to read.\n\n  * Topological sorting ([Wikipedia](<https://en.wikipedia.org/wiki/Topological_sorting>))\n  * Topological sort interactive visualization ([web](<https://www.cs.usfca.edu/~galles/visualization/TopoSortDFS.html>))\n\n## Recursive descent parsing\n\nThis one felt like unlocking a super power when it clicked for me. If you ever need to ingest a recursive data format or make a programming language, this is the tool for you. Sketch out a grammar then map each grammar rule to a code function. Bam! It feels like it codes itself.\n\n![](images/teenyparser.png)\n\nYou could have a simple compiler whipped up in a few hours with it.\n\n  * Let's make a Teeny Tiny compiler ([my tutorial series](<teenytinycompiler2.html>))\n  * Crafting Interpreters ([web](<https://craftinginterpreters.com/contents.html>), [Amazon](<https://amzn.to/3HT015y>))\n  * Recursive descent parser ([Wikipedia](<https://en.wikipedia.org/wiki/Recursive_descent_parser>))\n\n## Myers string diff\n\nProcessing strings is such a common programming task, but I can usually get away with brute forcing whatever it is I need to calculate. We've all learned about Levenshtein distance, but what if you need to show the differences between two strings in a sensible way?\n\n![](images/codediff.png)\n\nThe default algorithm used by git for showing diffs is the Myers diff algorithm.\n\n  * [The Myers diff algorithm](<https://blog.jcoglan.com/2017/02/12/the-myers-diff-algorithm-part-1/>)\n  * [Myers diff algorithm - Code and interactive visualization](<https://blog.robertelder.org/diff-algorithm/>)\n\n## Bloom filter\n\nThe most known unknown data structure. In fact, I polled some friends at Big Tech about what data structure they'd suggest I add to this list and _all of them_ said bloom filter!\n\nIt really only helps with large-scale problem, such as when you need a really big hash table, but it is a great introduction to _probabilistic data structures_. With very little memory, it can tell you if an item is _not_ present in the table, otherwise it can only tell you _maybe_ the item is present.\n\nGoogle asked me two interview problems involving these back when I was in college. Have I ever needed this in practice? Nope!\n\n  * Bloom filter ([Wikipedia](<https://en.wikipedia.org/wiki/Bloom_filter>))\n  * Let's implement a bloom filter ([web](<https://onatm.dev/2020/08/10/let-s-implement-a-bloom-filter/>))\n  * Bloom filters by example ([web](<https://llimllib.github.io/bloomfilter-tutorial/>))\n\n## Piece table\n\nWhen I first tried making my own text editor, I stored all of the text in an array. But that hits performance problems right away (e.g., when the user inserts text anywhere but the end). Years later I even got asked how to implement a performant text buffer at an internship interview.\n\nWhat should I have used? Well, there are a few options with different tradeoffs: rope, gap buffer, or piece table. With a piece table, you track the edits performed on text rather than only keeping the resulting text. It makes a lot of other features trivial to add (e.g., undo support and incremental saving).\n\nPiece tables aren't only useful for text editors though. You can use it whenever you have a large buffer of data that can be arbitrarily modified.\n\n  * Piece table ([Wikipedia](<https://en.wikipedia.org/wiki/Piece_table>))\n  * VS Code's text buffer story ([web](<https://code.visualstudio.com/blogs/2018/03/23/text-buffer-reimplementation>))\n  * The piece table ([web](<https://darrenburns.net/posts/piece-table/>))\n\n## Splay tree\n\nHow about a self-optimizing data structure? Splay trees are binary trees that will tend to have the more recently accessed elements closer to the root, and it does so without maintaining any additional metadata. Each time an element is accessed, it gets moved to the root.\n\n![](images/algorithmsbook.jpg)\n\nIt's a tree with a builtin cache and it is beautifully simple to implement! As a student, I had a really hard time implementing red-black trees (we wrote the code on paper, ugh) so I was pleasantly surprised when splay trees just clicked for me.\n\n  * Splay tree interactive visualization ([web](<https://www.cs.usfca.edu/~galles/visualization/SplayTree.html>))\n  * Splay tree ([Wikipedia](<https://en.wikipedia.org/wiki/Splay_tree>))\n  * Implementation in TypeScript ([GitHub](<https://github.com/w8r/splay-tree>))\n\n* * *\n\nIf you are still craving more, here are the honorable mentions that I cut from the list:\n\n  * Trie\n  * Segment tree\n  * Operational transformation\n  * Fibonacci heap\n  * Skip list\n  * Union find\n\nTry these out, and let me know if I missed any!\n\n  \n  \nThere are Amazon affiliate links on this page.","body_html":"<h2 id=\"austin-z-henley\">Austin Z. Henley</h2>\n<p>I build tools for people</p>\n<p><a href=\"mailto:austin.henley@microsoft.com\">austin.henley@microsoft.com</a><br />\n<a href=\"https://twitter.com/austinzhenley\" rel=\"nofollow ugc noopener\">@austinzhenley</a><br />\n<a href=\"https://github.com/AZHenley\" rel=\"nofollow ugc noopener\">github/AZHenley</a>  </p>\n<ul><li>* *</li></ul>\n<p>Home | Publications | Teaching | Blog</p>\n<ul><li>* *</li></ul>\n<h1 id=\"challenging-algorithms-and-data-structures-every-programmer-shou\">Challenging algorithms and data structures every programmer should try</h1>\n<p>12/21/2022  </p>\n<p><em>See the discussion of this post on<a href=\"https://www.reddit.com/r/programming/comments/zs0git/challenging_algorithms_and_data_structures_every/\" rel=\"nofollow ugc noopener\">Reddit</a> and <a href=\"https://news.ycombinator.com/item?id=34118450\" rel=\"nofollow ugc noopener\">Hacker News</a>.</em></p>\n<p>Alright, so we are all spending our leisure time reading about algorithms, right?</p>\n<p>Well, back when I was a student, my algorithms courses regularly put me to sleep. This is unfortunate because there are some <em>really</em> interesting algorithms and data structures out there. Not only have they come up during job interviews, but learning them changed how I think about problems. Plus they&#39;re useful even if you don&#39;t work on Google-scale problems.</p>\n<p>Following my other popular posts, challenging projects every programmer should try and more challenging projects every programmer should try, I made a list of interesting algorithms and data structures you should try:</p>\n<ul><li>Topological sort</li><li>Recursive descent parsing</li><li>Myers string difference</li><li>Bloom filter</li><li>Piece table</li><li>Splay tree</li></ul>\n<p><strong>Note:</strong> If you need an introduction to algorithms, I recommend Jeff Erickson&#39;s <em>Algorithms</em> (<a href=\"https://amzn.to/3G0v65I\" rel=\"nofollow ugc noopener\">Amazon</a>, <a href=\"http://jeffe.cs.illinois.edu/teaching/algorithms/?\" rel=\"nofollow ugc noopener\">web</a>) or Daniel Zingaro&#39;s <em>Algorithmic Thinking</em> (<a href=\"https://amzn.to/3HQYpJk\" rel=\"nofollow ugc noopener\">Amazon</a>). If you want a giant reference, then the classic is <em>Introduction to Algorithms</em> by CLRS (<a href=\"https://amzn.to/3hthlDv\" rel=\"nofollow ugc noopener\">Amazon</a>). Not enough? Watch MIT&#39;s Advanced Data Structures (<a href=\"https://www.youtube.com/playlist?list=PLUl4u3cNGP61hsJNdULdudlRL493b-XZf\" rel=\"nofollow ugc noopener\">YouTube</a>) to blow your mind.</p>\n<h2 id=\"topological-sort\">Topological sort</h2>\n<p>Anytime you need to sort items that are dependent on other items, you use topological sort. Common scenarios include determining the order of tasks for build systems, the evaluation order of cells in a spreadsheet, which classes a student should take each semester to graduate, and a variety of scheduling problems.</p>\n<p></p>\n<p>I even used it in graduate school to rearrange graphs to be easier to read.</p>\n<ul><li>Topological sorting (<a href=\"https://en.wikipedia.org/wiki/Topological_sorting\" rel=\"nofollow ugc noopener\">Wikipedia</a>)</li><li>Topological sort interactive visualization (<a href=\"https://www.cs.usfca.edu/~galles/visualization/TopoSortDFS.html\" rel=\"nofollow ugc noopener\">web</a>)</li></ul>\n<h2 id=\"recursive-descent-parsing\">Recursive descent parsing</h2>\n<p>This one felt like unlocking a super power when it clicked for me. If you ever need to ingest a recursive data format or make a programming language, this is the tool for you. Sketch out a grammar then map each grammar rule to a code function. Bam! It feels like it codes itself.</p>\n<p></p>\n<p>You could have a simple compiler whipped up in a few hours with it.</p>\n<ul><li>Let&#39;s make a Teeny Tiny compiler (my tutorial series)</li><li>Crafting Interpreters (<a href=\"https://craftinginterpreters.com/contents.html\" rel=\"nofollow ugc noopener\">web</a>, <a href=\"https://amzn.to/3HT015y\" rel=\"nofollow ugc noopener\">Amazon</a>)</li><li>Recursive descent parser (<a href=\"https://en.wikipedia.org/wiki/Recursive_descent_parser\" rel=\"nofollow ugc noopener\">Wikipedia</a>)</li></ul>\n<h2 id=\"myers-string-diff\">Myers string diff</h2>\n<p>Processing strings is such a common programming task, but I can usually get away with brute forcing whatever it is I need to calculate. We&#39;ve all learned about Levenshtein distance, but what if you need to show the differences between two strings in a sensible way?</p>\n<p></p>\n<p>The default algorithm used by git for showing diffs is the Myers diff algorithm.</p>\n<ul><li><a href=\"https://blog.jcoglan.com/2017/02/12/the-myers-diff-algorithm-part-1/\" rel=\"nofollow ugc noopener\">The Myers diff algorithm</a></li><li><a href=\"https://blog.robertelder.org/diff-algorithm/\" rel=\"nofollow ugc noopener\">Myers diff algorithm - Code and interactive visualization</a></li></ul>\n<h2 id=\"bloom-filter\">Bloom filter</h2>\n<p>The most known unknown data structure. In fact, I polled some friends at Big Tech about what data structure they&#39;d suggest I add to this list and <em>all of them</em> said bloom filter!</p>\n<p>It really only helps with large-scale problem, such as when you need a really big hash table, but it is a great introduction to <em>probabilistic data structures</em>. With very little memory, it can tell you if an item is <em>not</em> present in the table, otherwise it can only tell you <em>maybe</em> the item is present.</p>\n<p>Google asked me two interview problems involving these back when I was in college. Have I ever needed this in practice? Nope!</p>\n<ul><li>Bloom filter (<a href=\"https://en.wikipedia.org/wiki/Bloom_filter\" rel=\"nofollow ugc noopener\">Wikipedia</a>)</li><li>Let&#39;s implement a bloom filter (<a href=\"https://onatm.dev/2020/08/10/let-s-implement-a-bloom-filter/\" rel=\"nofollow ugc noopener\">web</a>)</li><li>Bloom filters by example (<a href=\"https://llimllib.github.io/bloomfilter-tutorial/\" rel=\"nofollow ugc noopener\">web</a>)</li></ul>\n<h2 id=\"piece-table\">Piece table</h2>\n<p>When I first tried making my own text editor, I stored all of the text in an array. But that hits performance problems right away (e.g., when the user inserts text anywhere but the end). Years later I even got asked how to implement a performant text buffer at an internship interview.</p>\n<p>What should I have used? Well, there are a few options with different tradeoffs: rope, gap buffer, or piece table. With a piece table, you track the edits performed on text rather than only keeping the resulting text. It makes a lot of other features trivial to add (e.g., undo support and incremental saving).</p>\n<p>Piece tables aren&#39;t only useful for text editors though. You can use it whenever you have a large buffer of data that can be arbitrarily modified.</p>\n<ul><li>Piece table (<a href=\"https://en.wikipedia.org/wiki/Piece_table\" rel=\"nofollow ugc noopener\">Wikipedia</a>)</li><li>VS Code&#39;s text buffer story (<a href=\"https://code.visualstudio.com/blogs/2018/03/23/text-buffer-reimplementation\" rel=\"nofollow ugc noopener\">web</a>)</li><li>The piece table (<a href=\"https://darrenburns.net/posts/piece-table/\" rel=\"nofollow ugc noopener\">web</a>)</li></ul>\n<h2 id=\"splay-tree\">Splay tree</h2>\n<p>How about a self-optimizing data structure? Splay trees are binary trees that will tend to have the more recently accessed elements closer to the root, and it does so without maintaining any additional metadata. Each time an element is accessed, it gets moved to the root.</p>\n<p></p>\n<p>It&#39;s a tree with a builtin cache and it is beautifully simple to implement! As a student, I had a really hard time implementing red-black trees (we wrote the code on paper, ugh) so I was pleasantly surprised when splay trees just clicked for me.</p>\n<ul><li>Splay tree interactive visualization (<a href=\"https://www.cs.usfca.edu/~galles/visualization/SplayTree.html\" rel=\"nofollow ugc noopener\">web</a>)</li><li>Splay tree (<a href=\"https://en.wikipedia.org/wiki/Splay_tree\" rel=\"nofollow ugc noopener\">Wikipedia</a>)</li><li>Implementation in TypeScript (<a href=\"https://github.com/w8r/splay-tree\" rel=\"nofollow ugc noopener\">GitHub</a>)</li><li>* *</li></ul>\n<p>If you are still craving more, here are the honorable mentions that I cut from the list:</p>\n<ul><li>Trie</li><li>Segment tree</li><li>Operational transformation</li><li>Fibonacci heap</li><li>Skip list</li><li>Union find</li></ul>\n<p>Try these out, and let me know if I missed any!</p>\n<p>There are Amazon affiliate links on this page.</p>","headings":[{"level":2,"text":"Austin Z. Henley","id":"austin-z-henley"},{"level":1,"text":"Challenging algorithms and data structures every programmer should try","id":"challenging-algorithms-and-data-structures-every-programmer-shou"},{"level":2,"text":"Topological sort","id":"topological-sort"},{"level":2,"text":"Recursive descent parsing","id":"recursive-descent-parsing"},{"level":2,"text":"Myers string diff","id":"myers-string-diff"},{"level":2,"text":"Bloom filter","id":"bloom-filter"},{"level":2,"text":"Piece table","id":"piece-table"},{"level":2,"text":"Splay tree","id":"splay-tree"}]}}