Skip to content

Commit a0eda6f

Browse files
committed
Menus tinkering
Removed prims_old, added hashing to search fn
1 parent 3e8db00 commit a0eda6f

File tree

4 files changed

+22
-7
lines changed

4 files changed

+22
-7
lines changed

src/algorithms/index.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ import * as Instructions from './instructions';
2222
src/context/actions.js had better be deployed!
2323
XXX Design of noDeploy stuff was done with the aim of minimal code change
2424
and could be re-thought when there are fewer merges going on.
25+
XXX This has now been totally ****ed up, with multiple lists of
26+
algorithms elsewhere (see components/mainmenu/index.js
27+
components/mainmenu/GraphAlgorithms.js components/AlgorithmMenu.js) as
28+
well as this file, algorithms/index.js. There should be *one* master
29+
list (eg, this one, possibly with extra info for each algorithm) and the
30+
other lists should be generated from the master list!
2531
2632
Each imported algorithm is expected to be an object of the form:
2733
{ pseudocode: String, explanation: String, run: Function }
@@ -332,7 +338,6 @@ const allalgs = {
332338
},
333339
controller: {
334340
find: Controller.dijkstra,
335-
336341
},
337342
},
338343
'aStar': {
@@ -347,7 +352,6 @@ const allalgs = {
347352
},
348353
controller: {
349354
find: Controller.AStar,
350-
351355
},
352356
},
353357
'prim': {
@@ -365,8 +369,10 @@ const allalgs = {
365369
find: Controller.prim,
366370
},
367371
},
372+
// Prim's (simpler code) is superseeded + could do with some work;
373+
// it's included here so it can be run but it's not included in menus
368374
'prim_old': {
369-
noDeploy: false,
375+
noDeploy: true,
370376
name: 'Prim\'s (simpler code)',
371377
category: 'Graph',
372378
explanation: Explanation.Prims_oldExp,

src/components/AlgorithmMenu.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import '../styles/AlgorithmMenu.scss';
55
const baseUrl = window.location.origin;
66

77
// XXX construct this from master list of algorithms!
8+
// or use this as master list
89
const algorithms = {
910
Sort: {
1011
Heapsort: `${baseUrl}/?alg=heapSort&mode=sort`,
@@ -23,7 +24,7 @@ const algorithms = {
2324
"Dijkstra's (shortest path)": `${baseUrl}/?alg=dijkstra&mode=find`,
2425
'A* (heuristic search)': `${baseUrl}/?alg=aStar&mode=find`,
2526
"Prim's (min. spanning tree)": `${baseUrl}/?alg=prim&mode=find`,
26-
"Prim's (simpler code)": `${baseUrl}/?alg=prim_old&mode=find`,
27+
// "Prim's (simpler code)": `${baseUrl}/?alg=prim_old&mode=find`,
2728
"Kruskal's (min. spanning tree)": `${baseUrl}/?alg=kruskal&mode=find`,
2829
"Warshall's (transitive closure)": `${baseUrl}/?alg=transitiveClosure&mode=tc`,
2930
},

src/components/mainmenu/GraphAlgorithms.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ import '../../styles/GraphAlgorithms.scss';
44
// Get the base URL dynamically
55
const baseUrl = window.location.origin;
66

7+
// XXX should have *one* list of algorithms and select based on category
78
const graphAlgorithms = [
89
{ name: 'Depth First Search', url: `${baseUrl}/?alg=DFSrec&mode=find` },
910
{ name: 'DFS (iterative)', url: `${baseUrl}/?alg=DFS&mode=find` },
1011
{ name: 'Breadth First Search', url: `${baseUrl}/?alg=BFS&mode=find` },
1112
{ name: "Dijkstra's (shortest path)", url: `${baseUrl}/?alg=dijkstra&mode=find` },
1213
{ name: 'A* (heuristic search)', url: `${baseUrl}/?alg=aStar&mode=find` },
1314
{ name: "Prim's (min. spanning tree)", url: `${baseUrl}/?alg=prim&mode=find` },
14-
{ name: "Prim's (simpler code)", url: `${baseUrl}/?alg=prim_old&mode=find` },
15+
// { name: "Prim's (simpler code)", url: `${baseUrl}/?alg=prim_old&mode=find` },
1516
{ name: "Kruskal's (min. spanning tree)", url: `${baseUrl}/?alg=kruskal&mode=find` },
1617
{ name: "Warshall's (transitive closure)", url: `${baseUrl}/?alg=transitiveClosure&mode=tc` }
1718
];

src/components/mainmenu/index.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@ import StringSearchAlgorithms from './StringSearchAlgorithms';
1111
// Get the base URL dynamically
1212
const baseUrl = window.location.origin;
1313

14-
// XXX should have algorithms just listed in one place
14+
// XXX should have algorithms just listed in one place!
1515
// (eg src/algorithms/index.js)
1616
// and filtered appropriately rather
1717
// than have multiple algorithm lists (here, above, SortingAlgorithms.js,
1818
// InsertSearchAlgorithms.js etc), as was done previously...
1919
// XXX also fix display code (see XXX elsewhere) - currently ugly and
2020
// broken; best just use something simple!
21+
// This version is used just(?) for the main menu search function
2122
const allAlgorithms = [
2223
{ name: 'Brute Force', url: `${baseUrl}/?alg=bruteForceStringSearch&mode=search` },
2324
{ name: "Horspool's", url: `${baseUrl}/?alg=horspoolStringSearch&mode=search` },
@@ -27,20 +28,25 @@ const allAlgorithms = [
2728
{ name: "Dijkstra's (shortest path)", url: `${baseUrl}/?alg=dijkstra&mode=find` },
2829
{ name: 'A* (heuristic search)', url: `${baseUrl}/?alg=aStar&mode=find` },
2930
{ name: "Prim's (min. spanning tree)", url: `${baseUrl}/?alg=prim&mode=find` },
31+
// prim_old not included in menus
3032
{ name: "Prim's (simpler code)", url: `${baseUrl}/?alg=prim_old&mode=find` },
3133
{ name: "Kruskal's (min. spanning tree)", url: `${baseUrl}/?alg=kruskal&mode=find` },
3234
{ name: "Warshall's (transitive closure)", url: `${baseUrl}/?alg=transitiveClosure&mode=tc` },
3335
{ name: 'Binary Search Tree', url: `${baseUrl}/?alg=binarySearchTree&mode=search` },
3436
{ name: '2-3-4 Tree', url: `${baseUrl}/?alg=TTFTree&mode=search` },
3537
{ name: 'AVL Tree', url: `${baseUrl}/?alg=AVLTree&mode=search` },
38+
{ name: 'Hashing (Linear Probing)', url: `${baseUrl}/?alg=HashingLP&mode=search` },
39+
{ name: 'Hashing (Double Hashing)', url: `${baseUrl}/?alg=HashingDH&mode=search` },
40+
{ name: 'Hashing (Chaining)', url: `${baseUrl}/?alg=HashingCH&mode=search` },
3641
{ name: 'Union Find', url: `${baseUrl}/?alg=unionFind&mode=find` },
3742
{ name: 'Heapsort', url: `${baseUrl}/?alg=heapSort&mode=sort` },
3843
{ name: 'Quicksort', url: `${baseUrl}/?alg=quickSort&mode=sort` },
3944
{ name: 'Quicksort (Median of 3)', url: `${baseUrl}/?alg=quickSortM3&mode=sort` },
4045
{ name: 'Merge Sort', url: `${baseUrl}/?alg=msort_arr_td&mode=sort` },
4146
{ name: 'Merge Sort (Bottom-up)', url: `${baseUrl}/?alg=msort_arr_bup&mode=sort` },
4247
{ name: 'Merge Sort (Natural)', url: `${baseUrl}/?alg=msort_arr_nat&mode=sort` },
43-
// XXX don't include list-array mergesort? msort_lista_td
48+
// msort_lista_td not included in menus
49+
{ name: 'Merge Sort (list rep. as array)', url: `${baseUrl}/?alg=msort_lista_td&mode=sort` },
4450
{ name: 'Radix Sort (MSD/Exchange)', url: `${baseUrl}/?alg=radixSortMSD&mode=sort` },
4551
{ name: 'Radix Sort (LSD/Straight)', url: `${baseUrl}/?alg=radixSortStraigh&mode=sort` },
4652
];
@@ -75,6 +81,7 @@ const Mainmenu = () => {
7581

7682
const filteredAlgorithms = allAlgorithms.filter(algorithm =>
7783
algorithm.name.toLowerCase().includes(searchTerm.toLowerCase())
84+
// XXX nice to add keyword search also
7885
);
7986
return (
8087
<div className="mainmenu-container">

0 commit comments

Comments
 (0)