# Tag Archives: Binary Indexed Tree

## XOR of elements in a given range with updates using Fenwick Tree

Given an array A[] of integers and array Q consisting of queries of the following two types: (1, L, R) : Return XOR of all… Read More »

## Queries for the number of nodes having values less than V in the subtree of a Node

Given a rooted tree (assume root is 1) of N nodes and Q queries, each of the form (Val, Node). For each query, the task… Read More »

## Count smaller elements on right side and greater elements on left side using Binary Index Tree

Given an array arr[] of size N. The task is to find smaller elements on the right side and greater elements on the left side… Read More »

## Find the number of pair of Ideal nodes in a given tree

Given a tree of N nodes and an integer K, each node is numbered between 1 and N. The task is to find the number… Read More »

## Range Sum Queries and Update with Square Root

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)

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

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 »

## XOR of numbers that appeared even number of times in given Range

Given an array of numbers of size N and Q queries. Each query or a range can be represented by L (LeftIndex) and R(RightIndex). Find… Read More »

## Sum of Interval and Update with Number of Divisors

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 »

## Array range queries over range queries

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 subarray

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 subarray

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 matrix

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)

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 »