# Tag Archives: Binary-Indexed-Tree

## Array range queries over range queriesSeptember 22, 2017

Given an array of size n and a give set of commands of size m. The commands are enumerated from 1 to m. These commands… Read More »

## Queries for number of distinct elements in a subarrayJune 18, 2017

Given a array ‘a[]’ of size n and number of queries q. Each query can be represented by two integers l and r. Your task… Read More »

## Number of elements less than or equal to a given number in a given subarrayJune 11, 2017

Given an array ‘a[]’ and number of queries q. Each query can be represented by l, r, x. Your task is to print the number… Read More »

## Count inversion pairs in a matrixJanuary 7, 2017

Given a matrix A of size NxN, we need to find the number of inversion pairs in it. Inversion count in a matrix is defined… Read More »

## proto van Emde Boas Trees | Set 1 (Background and Introduction)October 10, 2016

Let us consider the below problem statement and think of different solutions for it. Given a set S of elements such that the elements are… Read More »

## Binary Indexed Tree : Range Update and Range QueriesOctober 6, 2016

Given an array arr[0..n-1]. The following operations need to be performed. update(l, r, val) : Add ‘val’ to all the elements in the array from… Read More »

## How to prepare for ACM – ICPC?October 4, 2016

ACM ICPC(Association for Computing Machinery – International Collegiate Programming Contest) is a world-wide annual multi-tiered programming contest being organized for over thirteen years. The contest… Read More »

## Binary Indexed Tree : Range Updates and Point QueriesSeptember 30, 2016

Given an array arr[0..n-1]. The following operations need to be performed. update(l, r, val) : Add ‘val’ to all the elements in the array from… Read More »

## Finding the number of triangles amongst horizontal and vertical line segmentsAugust 9, 2016

Prerequisites: BIT Given ‘n’ line segments, each of them is either horizontal or vertical, find the maximum number of triangles(including triangles with zero area) that… Read More »

## Querying the number of distinct colors in a subtree of a colored tree using BITJuly 24, 2016

Prerequisites : BIT, DFS Given a rooted tree T, with ‘n’ nodes, each node has a color denoted by the array color[](color[i] denotes the color… Read More »

## Two Dimensional Binary Indexed Tree or Fenwick TreeJuly 16, 2016

Prerequisite – Fenwick Tree We know that to answer range sum queries on a 1-D array efficiently, binary indexed tree (or Fenwick Tree) is the… Read More »

## Counting Triangles in a Rectangular space using BITJuly 15, 2016

Pre-requisite : BIT(Binary Indexed Tree or Fenwick Tree), 2D BIT Given a 2D plane, respond to Q queries, each of the following type: Insert x… Read More »

## Count Inversions of size three in a given arrayDecember 21, 2015

Given an array arr[] of size n. Three elements arr[i], arr[j] and arr[k] form an inversion of size 3 if a[i] > a[j] >a[k] and… Read More »

## Count inversions in an array | Set 3 (Using BIT)December 18, 2015

Inversion Count for an array indicates – how far (or close) the array is from being sorted. If array is already sorted then inversion count… Read More »

## Top 10 Algorithms and Data Structures for Competitive ProgrammingDecember 16, 2015

In this post “Important top 10 algorithms and data structures for competitive coding “. Topics : Graph algorithms Dynamic programming Searching and Sorting: Number theory… Read More »