# Category Archives: Backtracking

## Queries to find the Minimum Weight from a Subtree of atmost D-distant Nodes from Node X

Given an N-ary Tree rooted at 1, and an array val[] consisting of weights assigned to every node, and a matrix Q[][], consisting of queries… Read More »

## N-Queen Problem | Local Search using Hill climbing with random neighbour

The N Queen is the problem of placing N chess queens on an N×N chessboard so that no two queens attack each other. For example,… Read More »

## Print all possible ways to write N as sum of two or more positive integers

Given an integer N, the task is to print all the possible ways in which N can be written as the sum of two or… Read More »

## Check if any King is unsafe on the Chessboard or not

Given a matrix board[][] consisting of the characters K or k, Q or q, B or b, N or n, R or r, and P… Read More »

## Split a Numeric String into Fibonacci Sequence

Given a numeric string S representing a large number, the task is to form a Fibonacci Sequence of at least length 3 from the given… Read More »

## Minimum Cost Path in a directed graph via given set of intermediate nodes

Given a weighted, directed graph G, an array V[] consisting of vertices, the task is to find the Minimum Cost Path passing through all the… Read More »

## Convert 1 into X in min steps by multiplying with 2 or 3 or by adding 1

Given an integer X, the task is to convert 1 into X by using the below-given operations:  Multiply the number by 2. Multiply the number… 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 »

## Maximal independent set from a given Graph using Backtracking

Given an undirected graph with V vertices and E edges, the task is to print all the independent sets and also find the maximal independent… Read More »

## Maximum size subset with given sum using Backtracking

Given an array arr[] consisting of N integers and an integer K, the task is to find the length of longest subsequence with sum equal… Read More »

## Number of times an array can be partitioned repetitively into two subarrays with equal sum

Given an array arr[] of size N, the task is to find the number of times the array can be partitioned repetitively into two subarrays… Read More »

## Unique subsequences of length K with given sum

Given an array arr[] of N integers and two numbers K and S, the task is to print all the subsquence of length K with… Read More »

## Minimum count of numbers required from given array to represent S

Given an integer S and an array arr[], the task is to find the minimum number of elements whose sum is S, such that any… Read More »

## Difference between Backtracking and Branch-N-Bound technique

Algorithms are the methodical sequence of steps which are defined to solve complex problems. In this article, we will see the difference between two such… Read More »

## Count the number of Prime Cliques in an undirected graph

Given a graph with N nodes and E edges, the task is to count the number of clique having their size as a prime number… Read More »