-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added psudeocode section to the UI with the aim of providing pseudocode for the search algorithm selected by the user. - Learnt an import React.js concept about "ligting up state". TODO: - Simply add the text for each algorithm's pseudocode where appropriate.
- Loading branch information
np57
committed
Jun 18, 2022
1 parent
8999264
commit 5d3a8be
Showing
5 changed files
with
153 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.pseudocode { | ||
margin-top: 10px; | ||
margin-left: 20px; | ||
text-align: left; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import React, { Component } from "react"; | ||
import "./Pseudocode.css"; | ||
|
||
class Pseudocode extends Component { | ||
|
||
|
||
// ATTRIBUTES (i.e., State): | ||
|
||
state = { | ||
selectedAlgorithm: null | ||
} | ||
|
||
|
||
// METHODS: | ||
|
||
// TODO: Add actual pseudocode text for each search algorithm. | ||
|
||
pseudocodeDijkstra = () => { | ||
|
||
return ( | ||
"Dijkstra's Algorithm" | ||
); | ||
|
||
} | ||
|
||
pseudocodeAStar = () => { | ||
|
||
return ( | ||
"A* Algorithm" | ||
); | ||
|
||
} | ||
|
||
pseudocodeGreedyBFS = () => { | ||
|
||
return ( | ||
"Greedy Best First Algorithm" | ||
); | ||
|
||
} | ||
|
||
pseudocodeBidirGreedy = () => { | ||
|
||
return ( | ||
"Bidirectional Greedy Algorithm" | ||
); | ||
|
||
} | ||
|
||
pseudocodeBFS = () => { | ||
|
||
return ( | ||
"Breadth First Search Algorithm" | ||
); | ||
|
||
} | ||
|
||
pseudocodeDFS = () => { | ||
|
||
return ( | ||
"Depth First Search Algorithm" | ||
); | ||
|
||
} | ||
|
||
pseudocodeRandomWalk = () => { | ||
|
||
return ( | ||
"Random Walk Algorithm" | ||
); | ||
|
||
} | ||
|
||
handlePseudocode = (algorithm) => { | ||
|
||
switch (algorithm) { | ||
case "Dijkstra": return this.pseudocodeDijkstra(); | ||
case "A*": return this.pseudocodeAStar(); | ||
case "Greedy BFS": return this.pseudocodeGreedyBFS(); | ||
case "Bidirectional Greedy": return this.pseudocodeBidirGreedy(); | ||
case "Breadth First Search": return this.pseudocodeBFS(); | ||
case "Depth First Search": return this.pseudocodeDFS(); | ||
case "Random Walk": return this.pseudocodeRandomWalk(); | ||
} | ||
|
||
} | ||
|
||
render() { | ||
|
||
const pseudoAlg = | ||
(this.props.algorithm === "Select an Algorithm!" || this.props.algorithm === "Visualize Algorithm") ? | ||
"" : | ||
this.props.algorithm.replace("Visualize ", "") | ||
|
||
return ( | ||
<div className="pseudocode"> | ||
<h4> Search Algorithm Pseudocode {(pseudoAlg === "") ? "" : " - " + pseudoAlg}</h4> | ||
<pre>{this.handlePseudocode(pseudoAlg)}</pre> | ||
</div> | ||
); | ||
|
||
} | ||
|
||
|
||
} | ||
|
||
export default Pseudocode; |