Practise Problems for Backtracking




1. Maze problem: http://interviewrack.blogspot.in/2017/03/maze-problem-backtracking.html


2. Search for words in matrix:

3. Permutations:

4. Sudoku: 
Given a partially filled 9×9 2D array ‘grid[9][9]’, the goal is to assign digits (from 1 to 9) to the empty cells so that every row, column, and subgrid of size 3×3 contains exactly one instance of the digits from 1 to 9.

5. The Word Break Problem:
Given an string and a dic­tio­nary of words, find out if the input string can be bro­ken into a space-separated sequence of one or more dic­tio­nary words.

6. N Queens Problem
In chess, a queen can move as far as she pleases, hor­i­zon­tally, ver­ti­cally, or diag­o­nally. A chessboard has 8 rows and 8 columns.
The stan­dard 8 by 8 Queen’s prob­lem asks how to place 8 queens on an ordi­nary chessboard so that none of them can attack any other in one move.

(A queen attacks another queen if the two are in the same row, column, or diagonal)

7. Landmines:
Given a path in the form of a rectangular matrix having few landmines arbitrarily placed (marked as 0), calculate length of the shortest safe route possible from any cell in the first column to any cell in the last column of the matrix.
We have to avoid landmines and their four adjacent cells (left, right, above and below) as they are also unsafe.
We are allowed to move to only adjacent cells which are not landmines. i.e. the route cannot contains any diagonal moves.

Comments

Popular posts from this blog

Java important topics list for interviews

Tough Sql practise questions for interviews involving SELECT queries - Part 2

DBMS important topics list for interviews

Program to find number lines and words in a given file

Tough Sql practise questions for interviews involving SELECT queries - Part 1

Producer Consumer Problem with Blocking Queue in Java.

Animation for String search - KMP Algorithm

Interactive Data Structure visualizations/animations for algorithms

Replace Occurances of the given string