<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Omar Ahmed Abdel Hameed</title>
    <description>The latest articles on Forem by Omar Ahmed Abdel Hameed (@omarahmedthe25th).</description>
    <link>https://forem.com/omarahmedthe25th</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3709849%2Fd426a465-90fb-4b7d-ba15-d0c9e9a6d4d0.jpg</url>
      <title>Forem: Omar Ahmed Abdel Hameed</title>
      <link>https://forem.com/omarahmedthe25th</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/omarahmedthe25th"/>
    <language>en</language>
    <item>
      <title>Why Scapegoat Trees Are Underrated (and My C++ Implementation)</title>
      <dc:creator>Omar Ahmed Abdel Hameed</dc:creator>
      <pubDate>Tue, 13 Jan 2026 21:22:36 +0000</pubDate>
      <link>https://forem.com/omarahmedthe25th/why-scapegoat-trees-are-underrated-and-my-c-implementation-5b7b</link>
      <guid>https://forem.com/omarahmedthe25th/why-scapegoat-trees-are-underrated-and-my-c-implementation-5b7b</guid>
      <description>&lt;p&gt;Ever felt like &lt;strong&gt;AVL trees are too strict&lt;/strong&gt; and &lt;strong&gt;Red-Black trees are way too picky&lt;/strong&gt;? Enter the &lt;strong&gt;Scapegoat Tree&lt;/strong&gt;—a balanced binary search tree that punishes misbehaving nodes only when necessary.&lt;/p&gt;

&lt;p&gt;I decided to implement one in &lt;strong&gt;C++26&lt;/strong&gt;, complete with &lt;strong&gt;Python bindings&lt;/strong&gt;, because sometimes the best learning comes from building things yourself—and because, honestly, they’re underrated and cool.&lt;/p&gt;




&lt;h2&gt;
  
  
  🚀 Features
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Automatic α-Weight balancing&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Insert, delete, search—all optimized&lt;/li&gt;
&lt;li&gt;Compute &lt;strong&gt;sum in range&lt;/strong&gt;, retrieve &lt;strong&gt;values in range&lt;/strong&gt;, find &lt;strong&gt;k-th smallest element&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Forward iterator support (yes, &lt;code&gt;for(auto x : tree)&lt;/code&gt; works!)&lt;/li&gt;
&lt;li&gt;Undo/Redo system&lt;/li&gt;
&lt;li&gt;Tree merging with duplicate handling&lt;/li&gt;
&lt;li&gt;Custom data structures: Vector, Queue, Stack&lt;/li&gt;
&lt;li&gt;Terminal UI for interactive exploration&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Basically, it’s the &lt;strong&gt;Swiss Army knife of BSTs&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  💻 How to Use
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/OmarAhmedTHE25th/ScapeGoatTree
&lt;span class="nb"&gt;cd &lt;/span&gt;ScapeGoatTree/CPP
&lt;span class="c"&gt;# Build and run your examples&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Python bindings are available for quick prototyping or testing.&lt;/p&gt;




&lt;h2&gt;
  
  
  🛠 Why It’s Cool
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Minimal STL usage—everything is built from scratch&lt;/li&gt;
&lt;li&gt;Clean API and operator overloading for intuitive syntax&lt;/li&gt;
&lt;li&gt;Extensive testing and interactive documentation available&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Check out the full API docs (&lt;a href="https://omarahmedthe25th.github.io" rel="noopener noreferrer"&gt;https://omarahmedthe25th.github.io&lt;/a&gt;).&lt;/p&gt;




&lt;h2&gt;
  
  
  🔗 Get Involved
&lt;/h2&gt;

&lt;p&gt;Open an issue, submit a PR, or just try it out! I’d love to see how others use the Scapegoat Tree in real projects.&lt;br&gt;
&lt;a href="https://github.com/OmarAhmedTHE25th/ScapeGoatTree" rel="noopener noreferrer"&gt;https://github.com/OmarAhmedTHE25th/ScapeGoatTree&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Tags:&lt;/strong&gt; &lt;code&gt;C++&lt;/code&gt;, &lt;code&gt;data-structures&lt;/code&gt;, &lt;code&gt;algorithms&lt;/code&gt;, &lt;code&gt;trees&lt;/code&gt;, &lt;code&gt;open-source&lt;/code&gt;, &lt;code&gt;Python&lt;/code&gt;&lt;/p&gt;

</description>
      <category>datastructures</category>
      <category>cpp</category>
      <category>programming</category>
      <category>algorithms</category>
    </item>
  </channel>
</rss>
