# Category Archives: Data Structures

This category is for logical grouping only. It needn’t to be added directly. Instead, the sub-categories should be added.

## Specific Level Order Traversal of Binary Tree

Given a Binary Tree, the task is to perform Specific Level Order Traversal of the tree such that at each level print 1st element then… Read More »

## Min difference between maximum and minimum element in all Y size subarrays

Given an array arr[] of size N and integer Y, the task is to find a minimum of all the differences between the maximum and… Read More »

## Create matrix whose sum of diagonals in each sub matrix is even

Given a number N, the task is to create a square matrix of size N*N with values in range [1, N*N], such that the sum… Read More »

## K most occurring strings

Given an array arr[] of N strings and an integer K, the task is to print K strings which occurred the most number of times… Read More »

## Queries for count of array elements with values in given range with updates

Given an array arr[] of size N and a matrix Q consisting of queries of the following two types: 1 L R : Print the… Read More »

## Median of sliding window in an array | Set 2

Prerequisites: Policy based data structure, Sliding window technique. Given an array of integer arr[] and an integer K, the task is to find the median… Read More »

## Maximal Independent Set in an Undirected Graph

Given an undirected graph defined by the number of vertex V and the edges E[ ], the task is to find Maximal Independent Vertex Set… Read More »

## Longest subarray with difference exactly K between any two distinct values

Given an array arr[] of length N and an integer K, the task is to find the longest subarray with difference between any two distict… Read More »

## Kth diagonal from the top left of a given matrix

Given a squared matrix M[ ][ ] of N * N dimensions, the task is to find the Kth diagonal of the matrix, starting from… Read More »

## Reverse a subarray to maximize sum of even-indexed elements of given array

Given an array arr[], the task is to maximize the sum of even-indexed elements by reversing a subarray and print the maximum sum obtained. Examples:… Read More »

## Construct a sequence from given frequencies of N consecutive integers with unit adjacent difference

Given an array freq[] which stores the frequency of N integers from 0 to N – 1. The task is to construct a sequence where… Read More »

## Replace all occurrences of character X with character Y in given string

Given a string str and two characters X and Y, the task is to write a recursive function to replace all occurrences of character X… Read More »

## Minimum distance between any most frequent and least frequent element of an array

Given an integer array arr[] of size N, the task is to find the minimum distance between any most and least frequent element of the… Read More »

## Check if frequency of each element in given array is unique or not

Given an array arr[] of N positive integers where the integers are in the range from 1 to N, the task is to check whether… Read More »

## How to store a very large number of more than 100 digits in C++

Given an integer N in form of string str consisting of more than 100 digits, the task is to store the value for performing an… Read More »