diff --git a/src/AppRouter.tsx b/src/AppRouter.tsx index 12daab1..c416d01 100644 --- a/src/AppRouter.tsx +++ b/src/AppRouter.tsx @@ -1,8 +1,10 @@ import { Routes, Route } from "react-router-dom"; - import Home from "./pages/Home"; import DynamicArray from "./pages/DynamicArray"; import Layout from "./Layout"; +import SinglyLinkedList from "./pages/SinglyLinkedList"; +import DoublyLinkedList from "./pages/DoublyLinkedList"; +import HashTable from "./pages/HashTable"; function AppRouter() { return ( @@ -10,6 +12,9 @@ function AppRouter() { }> } /> } /> + } /> + } /> + } /> ); diff --git a/src/components/DSPlaygrounds/DynamicArrayPG.tsx b/src/components/DSPlaygrounds/DynamicArrayPG.tsx index 6d2ea0a..25685ab 100644 --- a/src/components/DSPlaygrounds/DynamicArrayPG.tsx +++ b/src/components/DSPlaygrounds/DynamicArrayPG.tsx @@ -12,13 +12,10 @@ function DynamicArrayPG() { const [arrInput, setArrInput] = useState(JSON.stringify(state.array)); // arr-input const [pushInput, setPushInput] = useState(""); // push-input - const [resizingFactor, setResizingFactor] = useState("2"); // resizing factor input + const [resizingFactor, setResizingFactor] = useState(2); // resizing factor input const svgRef = useRef(null); // visualization state useEffect(() => { - // fill in any empty inputs - if (resizingFactor.length === 0) setResizingFactor("2"); - // update the visualization with the valid array state if (svgRef.current) { updateVisualization(); @@ -84,7 +81,7 @@ function DynamicArrayPG() { const newArray = [...prev.array, newValue]; let newCapacity = prev.capacity; if (newArray.length > prev.capacity) { - newCapacity = Math.ceil(prev.capacity * parseFloat(resizingFactor)); + newCapacity = Math.ceil(prev.capacity * resizingFactor); } return { array: newArray, @@ -127,7 +124,7 @@ function DynamicArrayPG() { const parsedInput = parseFloat(input); if (input === "" || parsedInput > 1) { - setResizingFactor(input); + setResizingFactor(parsedInput); } }; @@ -171,7 +168,7 @@ function DynamicArrayPG() {