1+ import { Helper } from "src/app/helper/helper"
2+
3+ const backtracking = {
4+ defination : `Think about a scenario where you are standing outside a maze, and you need to find the exit.
5+ Now, you have a couple of ways you can try to find the exit door, uncertain of the outcome. You may either run into some wrong
6+ path, backtrack(move back to the starting point) and try to find a new path, or one in many chances, you may land into the correct
7+ path and reach your exit door. But out of multiple scenarios, you have only one path(marked in green) which will lead you
8+ to the exit door.
9+ </br>
10+ For any backtracking problem, the backtracking algorithm tries to go through one of the paths to reach to the possible solution,
11+ and if the path doesn't leads them there, then the problem backtracks through the same path and takes another path in search of
12+ the solution.
13+ </br>
14+ To understand this clearly, consider the given example. Suppose you are standing in front of three roads, one of which is having
15+ a bag of gold at it's end, but you don't know which one it is. Firstly you will go in Path 1 , if that is not the one, then come
16+ out of it, and go into Path 2 , and again if that is not the one, come out of it and go into Path 3 . So, let's say we are standing
17+ at 'A' and we divided our problem into three smaller sub-probelms 'B', 'D' and 'F'. And using this sub-problem, we have three
18+ possible path to get to our solution -- 'C', 'E', & 'G'.` ,
19+
20+ example :'assets/ds-image/backtracking.jpg' ,
21+
22+ properties :[
23+ `A backtracking algorithm uses the depth-first search method. When it starts exploring the solutions, a bounding function is
24+ applied so that the algorithm can check if the so-far built solution satisfies the constraints. If it does, it continues
25+ searching. If it doesn’t, the branch would be eliminated, and the algorithm goes back to the level before.` ,
26+ `It uses recursive calling to find a solution set by building a solution step by step, increasing levels with time.
27+ In order to find these solutions, a search tree named state-space tree is used. In a state-space tree, each branch
28+ is a variable, and each level represents a solution.` ,
29+ `Backtracking is used to solve a problem that have multiple solutions.`
30+ ] ,
31+ types :[
32+ `Decision Problem – In this, we search for a feasible solution.` ,
33+ `Optimization Problem – In this, we search for the best solution.` ,
34+ `Enumeration Problem – In this, we find all feasible solutions.`
35+ ] ,
36+ advantage :[
37+ `Backtracking can almost solve any problems, due to its brute-force nature,
38+ although we use it to solve problems which have branching involved.` ,
39+ `Backtracking is an easy method to implement and contains fewer lines of code.`
40+ ] ,
41+ disadvantage : [
42+ `More optimal algorithms for the given problem may exist.` ,
43+ `When the branching factor is high, it is very time-consuming` ,
44+ `Large space complexity because we are using recursion so function information is stored on stack.`
45+ ] ,
46+ applications :[
47+ `To find all Hamiltonian Paths present in a graph.` ,
48+ `To solve the N Queen problem.` ,
49+ `Maze solving problem.` ,
50+ `The Knight's tour problem.` ,
51+ `Binary Strings: generating all binary strings` ,
52+ `Generating k – ary Strings` ,
53+ `The Knapsack Problem` ,
54+ `Graph Coloring Problem`
55+ ]
56+ }
57+
58+ export const backtrackingMetaData = {
59+ defination : Helper . setHeader ( backtracking . defination ) ,
60+ types : Helper . setListwithTitleHtml ( 'There are three types of problems in backtracking' , backtracking . types ) ,
61+ properties : Helper . setListwithTitleHtml ( 'Backtracking Algorithm Properties' , backtracking . properties ) ,
62+ example : Helper . setExampleImage ( 'Backtracking Example' , backtracking . example ) ,
63+ applications : Helper . setListwithTitleHtml ( 'Application of Backtracking' , backtracking . applications ) ,
64+ advantage : Helper . setListwithTitleHtml ( 'Advantage of Backtracking' , backtracking . advantage ) ,
65+ disadvantage : Helper . setListwithTitleHtml ( 'Disadvantage of Backtracking' , backtracking . disadvantage )
66+
67+ }
0 commit comments