Introduction Graph algorithms are the backbone of many computational problems, from network routing to social network analysis. Among the various graph algorithms, Heavy Light Decomposition (HLD) stands out as an advanced technique used to optimize c...
Welcome to Day 34 of my 100 Days of DSA challenge! Today, I delved into advanced Segment Tree concepts, focusing on optimizing range updates and queries using lazy propagation. These advanced techniques allow for efficient solutions to problems invol...
Welcome to Day 33 of my 100 Days of DSA challenge! Today’s focus was on mastering the fundamentals of segment trees, a versatile data structure designed for efficient range queries and updates. From implementing basic range sum queries to solving pro...
Let’s begin with some context, I learned segment tree in my college but I never practiced it thoroughly and it costed me couple of questions in recent codeforces rounds. Thus, I wanted to understand the segment tree more in depth, it’s flexibility an...
Recently, I came across a fascinating technique known as Fractional Cascading. Context I was solving KQUERY (SPOJ problem) KQUERY Given a sequence of n numbers a1, a2, ..., an and a number of k- queries. A k-query is a triple (i, j, k) (1 ≤ i ≤ j ≤ ...
Hey everyone! 🎉 I’m thrilled to share that this is the last chapter in my DSA with Java series! It’s been an incredible journey, and I’m excited to wrap it up with an important topic: Segment Trees. Segment trees are a powerful data structure, used ...
Segment Tree Basic Node Divide With Segment Tree Node Numbering (Segment Tree) // build (node, begin, end) build (1, 1, N) { L = 2xN, R = (2xN) + 1 // Node Number Calculate mid = (begin + end) / 2 left = (L, begin, mid) left = (R, ...
The PBDS (Policy-Based Data Structures) library, also known as the GNU Policy-Based Data Structures (PBDS) library, is an extension to the C++ Standard Template Library (STL) provided by GNU. It offers additional data structures that are not availabl...
Introduction Welcome Back! In this post, we will take a beginner's dive into segment trees in c++, we will look at what are they. what are they for? and we will solve some basic competitive programming problems together. Before we begin, I highly sug...
This article was first published in the author's personal blog: https://www.alice-bob.tech/the-root-n-trick/ Back in my days of competitive coding - I realized that there are two kinds of competitive coders - one who know binary indexed trees (BIT) ...