Binary Indexed Tree - Medium Articles

## Range Sum Queries and Update with Square Root 3.4

Given an array A of N integers and number of queries Q. You have to answer two types of queries. Update [l, r] – for… Read More »

## Number of elements greater than K in the range L to R using Fenwick Tree (Offline queries) 3.7

Prerequisites: Fenwick Tree (Binary Indexed Tree) Given an array of N numbers, and a number of queries where each query will contain three numbers(l, r… Read More »

## Count inversions of size k in a given array 3.5

Given an array of n distinct integers and an integer k. Find out the number of sub-sequences of a such that , and . In… Read More »

## Sum of Interval and Update with Number of Divisors 3.3

Given an array A of N integers. You have to answer two types of queries : 1. Update [l, r] – for every i in… Read More »

## Number of elements less than or equal to a given number in a given subarray 3.9

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 »

## Binary Indexed Tree : Range Updates and Point Queries 3.4

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 »

## Querying the number of distinct colors in a subtree of a colored tree using BIT 3.6

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 »

## Counting Triangles in a Rectangular space using BIT 3.4

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 array 3.8

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 »

## Top 10 Algorithms and Data Structures for Competitive Programming 3.4

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 »

## Binary Indexed Tree or Fenwick Tree 3.4

Let us consider the following problem to understand Binary Indexed Tree. We have an array arr[0 . . . n-1]. We would like to 1… Read More »