# Category: Expert

## Backtracking – Knight’s Tour Problem

Objective : A knight’s tour is a sequence of moves of a knight on a chessboard such that the knight visits every square only once. If the knight ends on a square that is...

## Backtracking – Search a Word In a Matrix

Objective : Given a 2D matrix of characters. Check whether the word exist in the matrix or not. If it exists then print its path. All movements are allowed (right, left, up, down and...

## Backtracking – N Queens Problem – Better Solution

Objective : In chess, a queen can move as far as she pleases, horizontally, vertically, or diagonally. A chess board has 8 rows and 8 columns. The standard 8 by 8 Queen’s problem asks...

## Backtracking – N Queens Problem

Objective : In chess, a queen can move as far as she pleases, horizontally, vertically, or diagonally. A chess board has 8 rows and 8 columns. The standard 8 by 8 Queen’s problem asks...

## Breadth-First Search/Traversal in a Graph.

Breadth-First Search ( or Tra­ver­sal)  in a Graph is quite similar to Binary Tree. Click here to read about BFS in Binary Tree. Example: What is Breadth First Search: Breadth-first search (BFS) is an...

## Backtracking – Rat In A Maze Puzzle

Given a maze, NxN matrix. A rat has to find a path from source to destination. maze[0][0] (left top corner)is the source and maze[N-1][N-1](right bottom corner) is destination. There are few cells which are...

## Backtracking – SUDOKU Solver

SUDOKU Puzzle : The objective is to fill a 9×9 grid with digits so that each column, each row, and each of the nine 3×3 sub-grids that compose the grid (also called “boxes”, “blocks”,...

## Merge K Sorted Arrays

Objective: Given k sorted array, write an algorithm to merge Them into One sorted array. Example : int[][] A = new int[5][]; A[0] = new int[] { 1, 5, 8, 9 }; A[1] =...

## Provide the Next Siblings Pointers in a Given Binary Tree

Objective: – Given a binary tree with three pointers left, right and nextSibling). Write the program to provide the nextsibling pointers. Example: Approach:

## Diameter Of a Binary Tree

Objective: – Given a binary tree, write an algorithm to find the diameter of the tree. What is Diameter Of a Tree: Diameter of tree is defined as A longest path or route between...

## Binary Min – Max Heap

A binary heap is a heap data structure created using a binary tree. binary tree has two rules – Binary Heap has to be complete binary tree at all levels except the last level....

## Colorful Numbers

Objective: Given a number, find out whether its colorful or not. Colorful Number: When in a given number, product of every digit of a sub-sequence are different. That number is called Colorful Number. See...

## Print All the Subsets of a Given Set (Power Set)

Objective: Given a set of numbers, print all the posssible subsets of it including empty set. Power Set: In mathematics, PowerSet of any given set S, PS(S) is set of all subsets of S...

## Print All Combinations of subset of size K from Given Array

Objective: Given an array of integers of size N, print all the subsets of size k. (k<=N) Example: Generate all subsets of a fixed size k of a given set [1,2,3…n]. e.g, if n=5...

## Print All Possible Valid Combinations Of Parenthesis of Given ‘N’

Objec­tive: – Given “n”, generate all valid parenthesis strings of length “2n”. Example: Given n=2 Output: (()) ()() Approach: