Segment Tree

A comprehensive introduction to Segment Tree

1. What is a Segment Tree?

Let’s say we have an array A of size N. A segment of the array is a contiguous part of an array in form A[i : j] such that 0 ≤ i ≤ j ≤ N-1.

A segment tree is essentially a binary tree…

Dynamic Programming: Equal Sum Partition Problem

Dynamic Programming Problem #3 : Equal Sum Partition

Before starting up with the Equal Sum Partition Problem, I would highly recommend you to read this introduction to Dynamic Programming. Here I have covered the basic method on how to approach a DP based problem. We will be using the same concepts to solve the Equal Sum Partition Problem

Dynamic Programming: Subset Sum Problem

Dynamic Programming Problem #2 : Subset Sum

Before starting up with the Subset Sum Problem, I would highly recommend you to read this introduction to Dynamic Programming. Here I have covered the basic method on how to approach a DP based problem. We will be using the same concepts to solve the Subset Sum problem. …

Dynamic Programming: 0–1 Knapsack

Dynamic Programming Problem #1 : 0–1 Knapsack

Before starting up with the Knapsack Problem, I would highly recommend you to read this introduction to Dynamic Programming. Here I have covered the basic method on how to approach a DP based problem. We will be using the same concepts to solve the Knapsack problem.

With that being said…

1. What is Dynamic Programming ?

In simple words, one can say that it is an optimization over plain recursion technique. This is achieved by reducing the number of recursive calls, either by storing the intermediate computed values or by deriving the final computation based on some kind of logical relation. …

What are Maps in STL ?

Maps are nothing but a type of associative container which stores elements in the form of key-value pairs. For those of you who are familiar with python, you can think of maps like a dictionary in python.

A key in map is used to uniquely identify the element and the…

Standard Template Library (STL) in C++ | Lists

Getting started with STL in C++

The Standard Template Library (STL) is a very useful set of template classes containing various containers. One among these containers is Lists. Today we’ll be having a look at Lists in STL. …

Iterators

Iterators are something which is used to point at the memory addresses of STL containers’ elements. Thus providing a means to access the data stored within the container and ability to modify them. They can be simply thought of as pointers.

Why Iterators ?

We need iterators in order to manipulate the containers…

Standard Template Library (STL) in C++ | Vectors

Getting started with STL in C++

The Standard Template Library (STL) in C++ is nothing but a set of template classes which provides us with the widely used data structures such as lists, stacks, maps, etc. along with iterators, functions and algorithms in order to play around with the data elements.

A. Main Components of STL

1. Containers

Containers are nothing but… Tanishq Vyas

Student at PES University.