File tree 5 files changed +25
-27
lines changed
5 files changed +25
-27
lines changed Original file line number Diff line number Diff line change @@ -118,17 +118,16 @@ const runAstar = (props: Props) => {
118
118
} , 100 / currentSpeed ) ;
119
119
} ;
120
120
121
- const aStarDesc =
122
- " ### A* Info\
123
- \nA* pronounced A-Star was originally created in an attempt to create a general purpose robot as part of the Shakey\
124
- project in the 1960’s and 70’s. A* is a best-first search algorithm.\
121
+ const aStarDesc = `### A* Info\
122
+ \nA\\* pronounced A-Star was originally created in an attempt to create a general purpose robot as part of the Shakey\
123
+ project in the 1960’s and 70’s. A\\* is a best-first search algorithm.\
125
124
\n### Runtime: \
126
125
\nThe time complexity is polynomial when the search space is a tree, there is a single goal state,\
127
126
and the heuristic function h meets the following condition:\
128
127
\n| h ( x ) − h ∗ ( x ) | = O ( log h ∗ ( x ) ) \
129
- \nwhere h* is the optimal heuristic, the exact cost to get from x to the goal.\
128
+ \nwhere h\\ * is the optimal heuristic, the exact cost to get from x to the goal.\
130
129
\n### Helpful links:\
131
130
\n[The Coding Train (video part1)] (https://www.youtube.com/watch?v=aKYlikFAV4k&t=968s) \
132
- \n[Computerphile (video)] (https://www.youtube.com/watch?v=ySN5Wnu88nE )" ;
131
+ \n[Computerphile (video)] (https://www.youtube.com/watch?v=ySN5Wnu88nE )` ;
133
132
134
133
export { runAstar , aStarDesc } ;
Original file line number Diff line number Diff line change @@ -70,14 +70,13 @@ const runBFS = (props: Props) => {
70
70
return ;
71
71
} ;
72
72
73
- const bfsDesc =
74
- "### BFS Info\
73
+ const bfsDesc = `### BFS Info\
75
74
\nBreadth-First Search is a graph or tree traversing algorithm that looks at all nodes at the current level \
76
75
before moving onto the next deepest set of nodes. It was created by Konrad Zuse in 1945 and later reinvented by Edward F. Moore in 1959. \
77
76
\n### Runtime:\
78
77
\nO( | V | + | E |) where V is the number of nodes and E the number of edges.\
79
78
\n### Helpful links: \
80
79
\n[TheHippieCat (video)] (https://www.youtube.com/watch?v=WvR9voi0y2I)\
81
- \n[Nesbox (README)] (https://github.com/nesbox/TIC-80/wiki/Pathfinding%EA%9E%89-BFS-Algorithm)" ;
80
+ \n[Nesbox (README)] (https://github.com/nesbox/TIC-80/wiki/Pathfinding%EA%9E%89-BFS-Algorithm)` ;
82
81
83
82
export { runBFS , bfsDesc } ;
Original file line number Diff line number Diff line change @@ -67,14 +67,13 @@ const runDFS = (props: Props) => {
67
67
} , 100 / currentSpeed ) ;
68
68
} ;
69
69
70
- const dfsDesc =
71
- "### DFS Info\
70
+ const dfsDesc = `### DFS Info\
72
71
\nDepth-first search is a pathfinding or tree spanning algorithm that follows one branch to its deepest point before backtracking. \
73
72
It was created in the 19th century by French mathematician Charles Pierre Trémaux. \
74
73
\n### Runtime:\
75
74
\nO( | V | + | E |) where V is the number of nodes and E the number of edges.\
76
75
\n### Helpful links:\
77
76
\n[Brilliant (articel)] (https://brilliant.org/wiki/depth-first-search-dfs)\
78
- \n[Go GATE IIT (video)](https://www.youtube.com/watch?v=iaBEKo5sM7w)" ;
77
+ \n[Go GATE IIT (video)](https://www.youtube.com/watch?v=iaBEKo5sM7w)` ;
79
78
80
79
export { runDFS , dfsDesc } ;
Original file line number Diff line number Diff line change @@ -96,15 +96,14 @@ const runDjikstras = (props: Props) => {
96
96
} , 100 / currentSpeed ) ;
97
97
} ;
98
98
99
- const djikstrasDesc =
100
- "### Djikstra's Algorithm Info\
99
+ const djikstrasDesc = `### Djikstra's Algorithm Info\
101
100
\nDjikstra's shortest path first Algorithm is a pathfinding algorithm created by Edsger W. Djikstra in 1956. \
102
101
It uses a min-priority queue to find the shortest path of a weighted graph. \
103
102
\n### Runtime: \
104
103
\n(Min-priority queue) O(| V | +| E |log| V |) (where | V | s the number of nodes and | E | is the number of edges)\
105
104
\n(Array) O(V^2)\
106
105
\n### Helpful links:\
107
106
\n[Computerphile (video)](https://www.youtube.com/watch?v=GazC3A4OQTE)\
108
- \n[Clément Mihailescu (video)] (https://www.youtube.com/watch?v=msttfIHHkak&t=2826s)" ;
107
+ \n[Clément Mihailescu (video)] (https://www.youtube.com/watch?v=msttfIHHkak&t=2826s)` ;
109
108
110
109
export { runDjikstras , djikstrasDesc } ;
Original file line number Diff line number Diff line change @@ -225,19 +225,21 @@ class MenuBar extends React.Component<MenuProps, _MenuState> {
225
225
} ;
226
226
227
227
getInfo = ( ) => {
228
- let al = this . props . selectedAlgo ;
229
- if ( al === null ) {
230
- al = "Select an algorithm" ;
231
- } else if ( al === Algorithms . astar ) {
232
- al = aStarDesc ;
233
- } else if ( al === Algorithms . bfs ) {
234
- al = bfsDesc ;
235
- } else if ( al === Algorithms . dfs ) {
236
- al = dfsDesc ;
237
- } else if ( al === Algorithms . djikstras ) {
238
- al = djikstrasDesc ;
228
+ const { selectedAlgo } = this . props ;
229
+ let algoDesc = "" ;
230
+
231
+ if ( selectedAlgo === null ) {
232
+ algoDesc = "Select an algorithm" ;
233
+ } else if ( selectedAlgo === Algorithms . astar ) {
234
+ algoDesc = aStarDesc ;
235
+ } else if ( selectedAlgo === Algorithms . bfs ) {
236
+ algoDesc = bfsDesc ;
237
+ } else if ( selectedAlgo === Algorithms . dfs ) {
238
+ algoDesc = dfsDesc ;
239
+ } else if ( selectedAlgo === Algorithms . djikstras ) {
240
+ algoDesc = djikstrasDesc ;
239
241
}
240
- return al as string ;
242
+ return algoDesc ;
241
243
} ;
242
244
243
245
render ( ) {
You can’t perform that action at this time.
0 commit comments