@tomaszjarosz/react-visualizers 0.4.12 → 0.4.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +616 -167
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.js +616 -167
- package/dist/index.js.map +1 -1
- package/dist/react-visualizers.css +20 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2052,13 +2052,13 @@ const BINARY_SEARCH_CODE = [
|
|
|
2052
2052
|
" right = mid - 1",
|
|
2053
2053
|
" return -1 // Not found"
|
|
2054
2054
|
];
|
|
2055
|
-
const LEGEND_ITEMS$
|
|
2055
|
+
const LEGEND_ITEMS$L = [
|
|
2056
2056
|
{ color: "bg-blue-100", label: "Search Space" },
|
|
2057
2057
|
{ color: "bg-gray-200", label: "Eliminated" },
|
|
2058
2058
|
{ color: "bg-purple-500", label: "Mid" },
|
|
2059
2059
|
{ color: "bg-green-500", label: "Found" }
|
|
2060
2060
|
];
|
|
2061
|
-
const BADGES$
|
|
2061
|
+
const BADGES$J = [
|
|
2062
2062
|
{ label: "Time: O(log n)", variant: "green" },
|
|
2063
2063
|
{ label: "Space: O(1)", variant: "green" }
|
|
2064
2064
|
];
|
|
@@ -2404,7 +2404,7 @@ const BinarySearchVisualizerComponent = ({
|
|
|
2404
2404
|
{
|
|
2405
2405
|
id: "binarysearch-visualizer",
|
|
2406
2406
|
title: "Binary Search",
|
|
2407
|
-
badges: BADGES$
|
|
2407
|
+
badges: BADGES$J,
|
|
2408
2408
|
gradient: "green",
|
|
2409
2409
|
className,
|
|
2410
2410
|
minHeight: 350,
|
|
@@ -2431,7 +2431,7 @@ const BinarySearchVisualizerComponent = ({
|
|
|
2431
2431
|
accentColor: "green"
|
|
2432
2432
|
},
|
|
2433
2433
|
showControls,
|
|
2434
|
-
legendItems: LEGEND_ITEMS$
|
|
2434
|
+
legendItems: LEGEND_ITEMS$L,
|
|
2435
2435
|
code: showCode ? BINARY_SEARCH_CODE : void 0,
|
|
2436
2436
|
currentCodeLine: currentStepData == null ? void 0 : currentStepData.codeLine,
|
|
2437
2437
|
codeVariables: currentStepData == null ? void 0 : currentStepData.variables,
|
|
@@ -2499,7 +2499,7 @@ const ALGORITHM_CODE = {
|
|
|
2499
2499
|
" else arr[k++] = right[j++]"
|
|
2500
2500
|
]
|
|
2501
2501
|
};
|
|
2502
|
-
const LEGEND_ITEMS$
|
|
2502
|
+
const LEGEND_ITEMS$K = [
|
|
2503
2503
|
{ color: "bg-blue-500", label: "Default" },
|
|
2504
2504
|
{ color: "bg-amber-400", label: "Comparing" },
|
|
2505
2505
|
{ color: "bg-red-500", label: "Swapping" },
|
|
@@ -3322,7 +3322,7 @@ const SortingVisualizerComponent = ({
|
|
|
3322
3322
|
extraControls: sizeControl
|
|
3323
3323
|
},
|
|
3324
3324
|
showControls,
|
|
3325
|
-
legendItems: LEGEND_ITEMS$
|
|
3325
|
+
legendItems: LEGEND_ITEMS$K,
|
|
3326
3326
|
code: showCode ? ALGORITHM_CODE[algorithm] : void 0,
|
|
3327
3327
|
currentCodeLine: currentStepData == null ? void 0 : currentStepData.codeLine,
|
|
3328
3328
|
codeVariables: currentStepData == null ? void 0 : currentStepData.variables,
|
|
@@ -3876,7 +3876,7 @@ const SortingComparisonVisualizerComponent = ({
|
|
|
3876
3876
|
);
|
|
3877
3877
|
};
|
|
3878
3878
|
const SortingComparisonVisualizer = React.memo(SortingComparisonVisualizerComponent);
|
|
3879
|
-
const BADGES$
|
|
3879
|
+
const BADGES$I = [
|
|
3880
3880
|
{ label: "Time: O((V+E) log V)", variant: "orange" },
|
|
3881
3881
|
{ label: "Space: O(V)", variant: "amber" }
|
|
3882
3882
|
];
|
|
@@ -3893,7 +3893,7 @@ const DIJKSTRA_CODE = [
|
|
|
3893
3893
|
" dist[v] = dist[u]+w",
|
|
3894
3894
|
" pq.add((dist[v], v))"
|
|
3895
3895
|
];
|
|
3896
|
-
const LEGEND_ITEMS$
|
|
3896
|
+
const LEGEND_ITEMS$J = [
|
|
3897
3897
|
{ color: "bg-blue-100", label: "Unvisited", border: "#60a5fa" },
|
|
3898
3898
|
{ color: "bg-yellow-400", label: "Current", border: "#ca8a04" },
|
|
3899
3899
|
{ color: "bg-green-400", label: "Visited", border: "#16a34a" }
|
|
@@ -4217,7 +4217,7 @@ const DijkstraVisualizerComponent = ({
|
|
|
4217
4217
|
{
|
|
4218
4218
|
id: VISUALIZER_ID2,
|
|
4219
4219
|
title: "Dijkstra's Algorithm",
|
|
4220
|
-
badges: BADGES$
|
|
4220
|
+
badges: BADGES$I,
|
|
4221
4221
|
gradient: "orange",
|
|
4222
4222
|
className,
|
|
4223
4223
|
minHeight: 500,
|
|
@@ -4241,7 +4241,7 @@ const DijkstraVisualizerComponent = ({
|
|
|
4241
4241
|
accentColor: "orange"
|
|
4242
4242
|
},
|
|
4243
4243
|
showControls,
|
|
4244
|
-
legendItems: LEGEND_ITEMS$
|
|
4244
|
+
legendItems: LEGEND_ITEMS$J,
|
|
4245
4245
|
code: showCode ? DIJKSTRA_CODE : void 0,
|
|
4246
4246
|
currentCodeLine: currentStepData == null ? void 0 : currentStepData.codeLine,
|
|
4247
4247
|
codeVariables: currentStepData == null ? void 0 : currentStepData.variables,
|
|
@@ -4258,7 +4258,7 @@ const DEFAULT_ITEMS$1 = [
|
|
|
4258
4258
|
{ weight: 5, value: 6 }
|
|
4259
4259
|
];
|
|
4260
4260
|
const DEFAULT_CAPACITY$1 = 8;
|
|
4261
|
-
const BADGES$
|
|
4261
|
+
const BADGES$H = [
|
|
4262
4262
|
{ label: "Time: O(nW)", variant: "teal" },
|
|
4263
4263
|
{ label: "Space: O(nW)", variant: "cyan" }
|
|
4264
4264
|
];
|
|
@@ -4272,7 +4272,7 @@ const KNAPSACK_CODE = [
|
|
|
4272
4272
|
" take = dp[i-1][w-weight] + value",
|
|
4273
4273
|
" dp[i][w] = max(skip, take)"
|
|
4274
4274
|
];
|
|
4275
|
-
const LEGEND_ITEMS$
|
|
4275
|
+
const LEGEND_ITEMS$I = [
|
|
4276
4276
|
{ color: "bg-gray-50", label: "Not computed", border: "#d1d5db" },
|
|
4277
4277
|
{ color: "bg-blue-100", label: "Computed" },
|
|
4278
4278
|
{ color: "bg-green-400", label: "Take item" },
|
|
@@ -4531,7 +4531,7 @@ const DPVisualizerComponent = ({
|
|
|
4531
4531
|
{
|
|
4532
4532
|
id: VISUALIZER_ID2,
|
|
4533
4533
|
title: "0/1 Knapsack (Dynamic Programming)",
|
|
4534
|
-
badges: BADGES$
|
|
4534
|
+
badges: BADGES$H,
|
|
4535
4535
|
gradient: "teal",
|
|
4536
4536
|
className,
|
|
4537
4537
|
minHeight: 450,
|
|
@@ -4555,7 +4555,7 @@ const DPVisualizerComponent = ({
|
|
|
4555
4555
|
accentColor: "teal"
|
|
4556
4556
|
},
|
|
4557
4557
|
showControls,
|
|
4558
|
-
legendItems: LEGEND_ITEMS$
|
|
4558
|
+
legendItems: LEGEND_ITEMS$I,
|
|
4559
4559
|
code: showCode ? KNAPSACK_CODE : void 0,
|
|
4560
4560
|
currentCodeLine: currentStepData == null ? void 0 : currentStepData.codeLine,
|
|
4561
4561
|
codeVariables: currentStepData == null ? void 0 : currentStepData.variables,
|
|
@@ -4597,7 +4597,7 @@ const BFS_CODE = [
|
|
|
4597
4597
|
" visited[neighbor] = true",
|
|
4598
4598
|
" queue.enqueue(neighbor)"
|
|
4599
4599
|
];
|
|
4600
|
-
const LEGEND_ITEMS$
|
|
4600
|
+
const LEGEND_ITEMS$H = [
|
|
4601
4601
|
{ color: "bg-blue-100", label: "Unvisited", border: "#60a5fa" },
|
|
4602
4602
|
{ color: "bg-yellow-400", label: "Current", border: "#ca8a04" },
|
|
4603
4603
|
{ color: "bg-green-400", label: "Visited", border: "#16a34a" }
|
|
@@ -5012,7 +5012,7 @@ const GraphVisualizerComponent = ({
|
|
|
5012
5012
|
accentColor: "purple"
|
|
5013
5013
|
},
|
|
5014
5014
|
showControls,
|
|
5015
|
-
legendItems: LEGEND_ITEMS$
|
|
5015
|
+
legendItems: LEGEND_ITEMS$H,
|
|
5016
5016
|
code: showCode ? algorithmCode : void 0,
|
|
5017
5017
|
currentCodeLine: currentStepData == null ? void 0 : currentStepData.codeLine,
|
|
5018
5018
|
codeVariables: currentStepData == null ? void 0 : currentStepData.variables,
|
|
@@ -5067,7 +5067,7 @@ const ASTAR_CODE = [
|
|
|
5067
5067
|
" openSet.add(neighbor)",
|
|
5068
5068
|
" return failure"
|
|
5069
5069
|
];
|
|
5070
|
-
const LEGEND_ITEMS$
|
|
5070
|
+
const LEGEND_ITEMS$G = [
|
|
5071
5071
|
{ color: "bg-green-500", label: "Start" },
|
|
5072
5072
|
{ color: "bg-red-500", label: "End" },
|
|
5073
5073
|
{ color: "bg-gray-700", label: "Wall" },
|
|
@@ -5076,7 +5076,7 @@ const LEGEND_ITEMS$F = [
|
|
|
5076
5076
|
{ color: "bg-yellow-400", label: "Current" },
|
|
5077
5077
|
{ color: "bg-purple-400", label: "Path" }
|
|
5078
5078
|
];
|
|
5079
|
-
const BADGES$
|
|
5079
|
+
const BADGES$G = [
|
|
5080
5080
|
{ label: "Time: O(E log V)", variant: "orange" },
|
|
5081
5081
|
{ label: "Optimal Path", variant: "orange" }
|
|
5082
5082
|
];
|
|
@@ -5376,7 +5376,7 @@ const AStarVisualizerComponent = ({
|
|
|
5376
5376
|
{
|
|
5377
5377
|
id: VISUALIZER_ID2,
|
|
5378
5378
|
title: "A* Pathfinding",
|
|
5379
|
-
badges: BADGES$
|
|
5379
|
+
badges: BADGES$G,
|
|
5380
5380
|
gradient: "orange",
|
|
5381
5381
|
className,
|
|
5382
5382
|
minHeight: 400,
|
|
@@ -5400,7 +5400,7 @@ const AStarVisualizerComponent = ({
|
|
|
5400
5400
|
accentColor: "orange"
|
|
5401
5401
|
},
|
|
5402
5402
|
showControls,
|
|
5403
|
-
legendItems: LEGEND_ITEMS$
|
|
5403
|
+
legendItems: LEGEND_ITEMS$G,
|
|
5404
5404
|
code: showCode ? ASTAR_CODE : void 0,
|
|
5405
5405
|
currentCodeLine: currentStepData == null ? void 0 : currentStepData.codeLine,
|
|
5406
5406
|
codeVariables: currentStepData == null ? void 0 : currentStepData.variables,
|
|
@@ -5445,14 +5445,14 @@ const TOPO_CODE = [
|
|
|
5445
5445
|
' return "Cycle detected!"',
|
|
5446
5446
|
" return result"
|
|
5447
5447
|
];
|
|
5448
|
-
const LEGEND_ITEMS$
|
|
5448
|
+
const LEGEND_ITEMS$F = [
|
|
5449
5449
|
{ color: "bg-gray-100", label: "Unprocessed", border: "#d1d5db" },
|
|
5450
5450
|
{ color: "bg-blue-400", label: "In queue" },
|
|
5451
5451
|
{ color: "bg-amber-400", label: "Processing" },
|
|
5452
5452
|
{ color: "bg-green-400", label: "Sorted" },
|
|
5453
5453
|
{ color: "bg-purple-200", label: "Edge being processed" }
|
|
5454
5454
|
];
|
|
5455
|
-
const BADGES$
|
|
5455
|
+
const BADGES$F = [
|
|
5456
5456
|
{ label: "Time: O(V+E)", variant: "blue" },
|
|
5457
5457
|
{ label: "Kahn Algorithm", variant: "cyan" }
|
|
5458
5458
|
];
|
|
@@ -5760,7 +5760,7 @@ const TopologicalSortVisualizerComponent = ({
|
|
|
5760
5760
|
{
|
|
5761
5761
|
id: VISUALIZER_ID2,
|
|
5762
5762
|
title: "Topological Sort",
|
|
5763
|
-
badges: BADGES$
|
|
5763
|
+
badges: BADGES$F,
|
|
5764
5764
|
gradient: "cyan",
|
|
5765
5765
|
className,
|
|
5766
5766
|
minHeight: 400,
|
|
@@ -5784,7 +5784,7 @@ const TopologicalSortVisualizerComponent = ({
|
|
|
5784
5784
|
accentColor: "cyan"
|
|
5785
5785
|
},
|
|
5786
5786
|
showControls,
|
|
5787
|
-
legendItems: LEGEND_ITEMS$
|
|
5787
|
+
legendItems: LEGEND_ITEMS$F,
|
|
5788
5788
|
code: showCode ? TOPO_CODE : void 0,
|
|
5789
5789
|
currentCodeLine: currentStepData == null ? void 0 : currentStepData.codeLine,
|
|
5790
5790
|
codeVariables: currentStepData == null ? void 0 : currentStepData.variables,
|
|
@@ -5827,13 +5827,13 @@ const HASHMAP_CODE = [
|
|
|
5827
5827
|
" return entry.value",
|
|
5828
5828
|
" return null"
|
|
5829
5829
|
];
|
|
5830
|
-
const LEGEND_ITEMS$
|
|
5830
|
+
const LEGEND_ITEMS$E = [
|
|
5831
5831
|
{ color: "bg-blue-50", label: "Current bucket", border: "#60a5fa" },
|
|
5832
5832
|
{ color: "bg-blue-500", label: "Insert/Update" },
|
|
5833
5833
|
{ color: "bg-green-400", label: "Found" },
|
|
5834
5834
|
{ color: "bg-red-400", label: "Not found" }
|
|
5835
5835
|
];
|
|
5836
|
-
const BADGES$
|
|
5836
|
+
const BADGES$E = [
|
|
5837
5837
|
{ label: "Avg: O(1)", variant: "indigo" },
|
|
5838
5838
|
{ label: "Worst: O(n)", variant: "purple" }
|
|
5839
5839
|
];
|
|
@@ -6094,7 +6094,7 @@ const HashMapVisualizerComponent = ({
|
|
|
6094
6094
|
{
|
|
6095
6095
|
id: VISUALIZER_ID2,
|
|
6096
6096
|
title: "HashMap Operations",
|
|
6097
|
-
badges: BADGES$
|
|
6097
|
+
badges: BADGES$E,
|
|
6098
6098
|
gradient: "indigo",
|
|
6099
6099
|
onShare: handleShare,
|
|
6100
6100
|
className,
|
|
@@ -6118,7 +6118,7 @@ const HashMapVisualizerComponent = ({
|
|
|
6118
6118
|
accentColor: "indigo"
|
|
6119
6119
|
},
|
|
6120
6120
|
showControls,
|
|
6121
|
-
legendItems: LEGEND_ITEMS$
|
|
6121
|
+
legendItems: LEGEND_ITEMS$E,
|
|
6122
6122
|
code: showCode ? HASHMAP_CODE : void 0,
|
|
6123
6123
|
currentCodeLine: currentStepData == null ? void 0 : currentStepData.codeLine,
|
|
6124
6124
|
codeVariables: currentStepData == null ? void 0 : currentStepData.variables,
|
|
@@ -6167,7 +6167,7 @@ const LRU_CODE = [
|
|
|
6167
6167
|
" addToHead(node)",
|
|
6168
6168
|
" cache[key] = node"
|
|
6169
6169
|
];
|
|
6170
|
-
const LEGEND_ITEMS$
|
|
6170
|
+
const LEGEND_ITEMS$D = [
|
|
6171
6171
|
{ color: "bg-gray-100", label: "Cache entry", border: "#d1d5db" },
|
|
6172
6172
|
{ color: "bg-green-400", label: "Head (MRU)" },
|
|
6173
6173
|
{ color: "bg-red-400", label: "Tail (LRU)" },
|
|
@@ -6175,7 +6175,7 @@ const LEGEND_ITEMS$C = [
|
|
|
6175
6175
|
{ color: "bg-yellow-200", label: "Cache hit", border: "#fbbf24" },
|
|
6176
6176
|
{ color: "bg-purple-400", label: "Evicted" }
|
|
6177
6177
|
];
|
|
6178
|
-
const BADGES$
|
|
6178
|
+
const BADGES$D = [
|
|
6179
6179
|
{ label: "O(1) get/put", variant: "orange" },
|
|
6180
6180
|
{ label: "HashMap + DLL", variant: "orange" }
|
|
6181
6181
|
];
|
|
@@ -6528,7 +6528,7 @@ const LRUCacheVisualizerComponent = ({
|
|
|
6528
6528
|
{
|
|
6529
6529
|
id: VISUALIZER_ID2,
|
|
6530
6530
|
title: "LRU Cache",
|
|
6531
|
-
badges: BADGES$
|
|
6531
|
+
badges: BADGES$D,
|
|
6532
6532
|
gradient: "orange",
|
|
6533
6533
|
className,
|
|
6534
6534
|
minHeight: 380,
|
|
@@ -6552,7 +6552,7 @@ const LRUCacheVisualizerComponent = ({
|
|
|
6552
6552
|
accentColor: "orange"
|
|
6553
6553
|
},
|
|
6554
6554
|
showControls,
|
|
6555
|
-
legendItems: LEGEND_ITEMS$
|
|
6555
|
+
legendItems: LEGEND_ITEMS$D,
|
|
6556
6556
|
code: showCode ? LRU_CODE : void 0,
|
|
6557
6557
|
currentCodeLine: currentStepData == null ? void 0 : currentStepData.codeLine,
|
|
6558
6558
|
codeVariables: currentStepData == null ? void 0 : currentStepData.variables,
|
|
@@ -6562,9 +6562,9 @@ const LRUCacheVisualizerComponent = ({
|
|
|
6562
6562
|
);
|
|
6563
6563
|
};
|
|
6564
6564
|
const LRUCacheVisualizer = React.memo(LRUCacheVisualizerComponent);
|
|
6565
|
-
const VISUALIZER_ID$
|
|
6565
|
+
const VISUALIZER_ID$a = "hashmap-interview-visualizer";
|
|
6566
6566
|
const BUCKET_COUNT$1 = 8;
|
|
6567
|
-
const BADGES$
|
|
6567
|
+
const BADGES$C = [
|
|
6568
6568
|
{ label: "Interview Mode", variant: "purple" },
|
|
6569
6569
|
{ label: "O(1) avg", variant: "green" },
|
|
6570
6570
|
{ label: "Hash Table", variant: "indigo" }
|
|
@@ -6578,7 +6578,7 @@ const OPERATIONS$l = [
|
|
|
6578
6578
|
{ op: "put", key: "Alice", value: 26 },
|
|
6579
6579
|
{ op: "get", key: "Frank" }
|
|
6580
6580
|
];
|
|
6581
|
-
const LEGEND_ITEMS$
|
|
6581
|
+
const LEGEND_ITEMS$C = [
|
|
6582
6582
|
{ color: "bg-blue-50", label: "Current bucket", border: "#60a5fa" },
|
|
6583
6583
|
{ color: "bg-blue-500", label: "Insert/Update" },
|
|
6584
6584
|
{ color: "bg-green-400", label: "Found" },
|
|
@@ -6800,7 +6800,7 @@ const HashMapInterviewVisualizerComponent = ({
|
|
|
6800
6800
|
showControls = true,
|
|
6801
6801
|
className = ""
|
|
6802
6802
|
}) => {
|
|
6803
|
-
const { copyUrlToClipboard } = useUrlState({ prefix: "hm-int", scrollToId: VISUALIZER_ID$
|
|
6803
|
+
const { copyUrlToClipboard } = useUrlState({ prefix: "hm-int", scrollToId: VISUALIZER_ID$a });
|
|
6804
6804
|
const [mode, setMode] = React.useState("visualize");
|
|
6805
6805
|
const generateSteps = React.useMemo(() => generateHashMapSteps, []);
|
|
6806
6806
|
const {
|
|
@@ -6904,9 +6904,9 @@ const HashMapInterviewVisualizerComponent = ({
|
|
|
6904
6904
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6905
6905
|
BaseVisualizerLayout,
|
|
6906
6906
|
{
|
|
6907
|
-
id: VISUALIZER_ID$
|
|
6907
|
+
id: VISUALIZER_ID$a,
|
|
6908
6908
|
title: "HashMap (Interview Mode)",
|
|
6909
|
-
badges: BADGES$
|
|
6909
|
+
badges: BADGES$C,
|
|
6910
6910
|
gradient: "indigo",
|
|
6911
6911
|
className,
|
|
6912
6912
|
minHeight: 500,
|
|
@@ -6930,7 +6930,7 @@ const HashMapInterviewVisualizerComponent = ({
|
|
|
6930
6930
|
accentColor: "indigo"
|
|
6931
6931
|
},
|
|
6932
6932
|
showControls,
|
|
6933
|
-
legendItems: LEGEND_ITEMS$
|
|
6933
|
+
legendItems: LEGEND_ITEMS$C,
|
|
6934
6934
|
sidePanel,
|
|
6935
6935
|
children: visualization
|
|
6936
6936
|
}
|
|
@@ -6947,10 +6947,10 @@ const OPERATIONS$k = [
|
|
|
6947
6947
|
{ op: "removeLast" },
|
|
6948
6948
|
{ op: "removeMiddle", index: 2 }
|
|
6949
6949
|
];
|
|
6950
|
-
const BADGES$
|
|
6950
|
+
const BADGES$B = [
|
|
6951
6951
|
{ label: "Comparison", variant: "blue" }
|
|
6952
6952
|
];
|
|
6953
|
-
const LEGEND_ITEMS$
|
|
6953
|
+
const LEGEND_ITEMS$B = [
|
|
6954
6954
|
{ color: "bg-blue-500", label: "ArrayList" },
|
|
6955
6955
|
{ color: "bg-green-500", label: "LinkedList" },
|
|
6956
6956
|
{ color: "bg-amber-400", label: "Current element" },
|
|
@@ -7445,7 +7445,7 @@ const ListComparisonVisualizerComponent = ({
|
|
|
7445
7445
|
{
|
|
7446
7446
|
id: VISUALIZER_ID2,
|
|
7447
7447
|
title: "ArrayList vs LinkedList",
|
|
7448
|
-
badges: BADGES$
|
|
7448
|
+
badges: BADGES$B,
|
|
7449
7449
|
gradient: "blue",
|
|
7450
7450
|
className,
|
|
7451
7451
|
minHeight: 400,
|
|
@@ -7469,14 +7469,14 @@ const ListComparisonVisualizerComponent = ({
|
|
|
7469
7469
|
accentColor: "blue"
|
|
7470
7470
|
},
|
|
7471
7471
|
showControls,
|
|
7472
|
-
legendItems: LEGEND_ITEMS$
|
|
7472
|
+
legendItems: LEGEND_ITEMS$B,
|
|
7473
7473
|
children: visualization
|
|
7474
7474
|
}
|
|
7475
7475
|
);
|
|
7476
7476
|
};
|
|
7477
7477
|
const ListComparisonVisualizer = React.memo(ListComparisonVisualizerComponent);
|
|
7478
|
-
const VISUALIZER_ID$
|
|
7479
|
-
const BADGES$
|
|
7478
|
+
const VISUALIZER_ID$9 = "treeset-interview-visualizer";
|
|
7479
|
+
const BADGES$A = [
|
|
7480
7480
|
{ label: "Interview Mode", variant: "purple" },
|
|
7481
7481
|
{ label: "BST", variant: "green" },
|
|
7482
7482
|
{ label: "O(log n)", variant: "teal" }
|
|
@@ -7492,7 +7492,7 @@ const OPERATIONS$j = [
|
|
|
7492
7492
|
{ op: "contains", value: 40 },
|
|
7493
7493
|
{ op: "contains", value: 55 }
|
|
7494
7494
|
];
|
|
7495
|
-
const LEGEND_ITEMS$
|
|
7495
|
+
const LEGEND_ITEMS$A = [
|
|
7496
7496
|
{ color: "bg-yellow-100", label: "Path", border: "#facc15" },
|
|
7497
7497
|
{ color: "bg-green-500", label: "Current/Found" },
|
|
7498
7498
|
{ color: "bg-red-500", label: "Not found" }
|
|
@@ -7717,7 +7717,7 @@ const TreeSetInterviewVisualizerComponent = ({
|
|
|
7717
7717
|
showControls = true,
|
|
7718
7718
|
className = ""
|
|
7719
7719
|
}) => {
|
|
7720
|
-
const { copyUrlToClipboard } = useUrlState({ prefix: "ts-int", scrollToId: VISUALIZER_ID$
|
|
7720
|
+
const { copyUrlToClipboard } = useUrlState({ prefix: "ts-int", scrollToId: VISUALIZER_ID$9 });
|
|
7721
7721
|
const [mode, setMode] = React.useState("visualize");
|
|
7722
7722
|
const generateSteps = React.useMemo(() => generateTreeSetSteps$1, []);
|
|
7723
7723
|
const {
|
|
@@ -7861,9 +7861,9 @@ const TreeSetInterviewVisualizerComponent = ({
|
|
|
7861
7861
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
7862
7862
|
BaseVisualizerLayout,
|
|
7863
7863
|
{
|
|
7864
|
-
id: VISUALIZER_ID$
|
|
7864
|
+
id: VISUALIZER_ID$9,
|
|
7865
7865
|
title: "TreeSet / BST (Interview Mode)",
|
|
7866
|
-
badges: BADGES$
|
|
7866
|
+
badges: BADGES$A,
|
|
7867
7867
|
gradient: "green",
|
|
7868
7868
|
className,
|
|
7869
7869
|
minHeight: 500,
|
|
@@ -7887,19 +7887,19 @@ const TreeSetInterviewVisualizerComponent = ({
|
|
|
7887
7887
|
accentColor: "green"
|
|
7888
7888
|
},
|
|
7889
7889
|
showControls,
|
|
7890
|
-
legendItems: LEGEND_ITEMS$
|
|
7890
|
+
legendItems: LEGEND_ITEMS$A,
|
|
7891
7891
|
sidePanel,
|
|
7892
7892
|
children: visualization
|
|
7893
7893
|
}
|
|
7894
7894
|
);
|
|
7895
7895
|
};
|
|
7896
7896
|
const TreeSetInterviewVisualizer = React.memo(TreeSetInterviewVisualizerComponent);
|
|
7897
|
-
const VISUALIZER_ID$
|
|
7898
|
-
const INITIAL_ARRAY$
|
|
7899
|
-
const BADGES$
|
|
7897
|
+
const VISUALIZER_ID$8 = "sorting-interview-visualizer";
|
|
7898
|
+
const INITIAL_ARRAY$2 = [64, 34, 25, 12, 22, 11, 90];
|
|
7899
|
+
const BADGES$z = [
|
|
7900
7900
|
{ label: "O(n log n) avg", variant: "amber" }
|
|
7901
7901
|
];
|
|
7902
|
-
const LEGEND_ITEMS$
|
|
7902
|
+
const LEGEND_ITEMS$z = [
|
|
7903
7903
|
{ color: "bg-amber-400", label: "Comparing" },
|
|
7904
7904
|
{ color: "bg-red-400", label: "Swapping" },
|
|
7905
7905
|
{ color: "bg-green-400", label: "Sorted" },
|
|
@@ -8095,16 +8095,16 @@ const SortingInterviewVisualizerComponent = ({
|
|
|
8095
8095
|
showControls = true,
|
|
8096
8096
|
className = ""
|
|
8097
8097
|
}) => {
|
|
8098
|
-
const { copyUrlToClipboard } = useUrlState({ prefix: "sort-int", scrollToId: VISUALIZER_ID$
|
|
8098
|
+
const { copyUrlToClipboard } = useUrlState({ prefix: "sort-int", scrollToId: VISUALIZER_ID$8 });
|
|
8099
8099
|
const [mode, setMode] = React.useState("visualize");
|
|
8100
|
-
const generateSteps = React.useMemo(() => () => generateQuickSortSteps(INITIAL_ARRAY$
|
|
8100
|
+
const generateSteps = React.useMemo(() => () => generateQuickSortSteps(INITIAL_ARRAY$2), []);
|
|
8101
8101
|
const playback = useVisualizerPlayback({ generateSteps });
|
|
8102
8102
|
const interview = useInterviewMode({
|
|
8103
8103
|
questions: SORTING_QUESTIONS,
|
|
8104
8104
|
shuffleQuestions: true
|
|
8105
8105
|
});
|
|
8106
8106
|
const stepData = playback.currentStepData || {
|
|
8107
|
-
array: INITIAL_ARRAY$
|
|
8107
|
+
array: INITIAL_ARRAY$2,
|
|
8108
8108
|
description: ""
|
|
8109
8109
|
};
|
|
8110
8110
|
const { array, comparing, swapping, sorted, pivot, description } = stepData;
|
|
@@ -8184,9 +8184,9 @@ const SortingInterviewVisualizerComponent = ({
|
|
|
8184
8184
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
8185
8185
|
BaseVisualizerLayout,
|
|
8186
8186
|
{
|
|
8187
|
-
id: VISUALIZER_ID$
|
|
8187
|
+
id: VISUALIZER_ID$8,
|
|
8188
8188
|
title: "QuickSort (Interview Mode)",
|
|
8189
|
-
badges: BADGES$
|
|
8189
|
+
badges: BADGES$z,
|
|
8190
8190
|
gradient: "orange",
|
|
8191
8191
|
className,
|
|
8192
8192
|
minHeight: 500,
|
|
@@ -8211,15 +8211,15 @@ const SortingInterviewVisualizerComponent = ({
|
|
|
8211
8211
|
accentColor: "orange"
|
|
8212
8212
|
},
|
|
8213
8213
|
showControls,
|
|
8214
|
-
legendItems: LEGEND_ITEMS$
|
|
8214
|
+
legendItems: LEGEND_ITEMS$z,
|
|
8215
8215
|
sidePanel,
|
|
8216
8216
|
children: visualization
|
|
8217
8217
|
}
|
|
8218
8218
|
);
|
|
8219
8219
|
};
|
|
8220
8220
|
const SortingInterviewVisualizer = React.memo(SortingInterviewVisualizerComponent);
|
|
8221
|
-
const VISUALIZER_ID$
|
|
8222
|
-
const BADGES$
|
|
8221
|
+
const VISUALIZER_ID$7 = "graph-interview-visualizer";
|
|
8222
|
+
const BADGES$y = [
|
|
8223
8223
|
{ label: "Interview Mode", variant: "purple" },
|
|
8224
8224
|
{ label: "BFS/DFS", variant: "blue" },
|
|
8225
8225
|
{ label: "O(V+E)", variant: "cyan" }
|
|
@@ -8242,7 +8242,7 @@ const EDGES$1 = [
|
|
|
8242
8242
|
{ from: "C", to: "G" },
|
|
8243
8243
|
{ from: "E", to: "F" }
|
|
8244
8244
|
];
|
|
8245
|
-
const LEGEND_ITEMS$
|
|
8245
|
+
const LEGEND_ITEMS$y = [
|
|
8246
8246
|
{ color: "bg-blue-500", label: "Current" },
|
|
8247
8247
|
{ color: "bg-green-400", label: "Visited" },
|
|
8248
8248
|
{ color: "bg-yellow-100", label: "In Queue/Stack", border: "#facc15" }
|
|
@@ -8468,7 +8468,7 @@ const GraphInterviewVisualizerComponent = ({
|
|
|
8468
8468
|
className = ""
|
|
8469
8469
|
}) => {
|
|
8470
8470
|
var _a;
|
|
8471
|
-
const { copyUrlToClipboard } = useUrlState({ prefix: "graph-int", scrollToId: VISUALIZER_ID$
|
|
8471
|
+
const { copyUrlToClipboard } = useUrlState({ prefix: "graph-int", scrollToId: VISUALIZER_ID$7 });
|
|
8472
8472
|
const [mode, setMode] = React.useState("visualize");
|
|
8473
8473
|
const [algorithm, setAlgorithm] = React.useState("bfs");
|
|
8474
8474
|
const generateSteps = React.useMemo(
|
|
@@ -8620,9 +8620,9 @@ const GraphInterviewVisualizerComponent = ({
|
|
|
8620
8620
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
8621
8621
|
BaseVisualizerLayout,
|
|
8622
8622
|
{
|
|
8623
|
-
id: VISUALIZER_ID$
|
|
8623
|
+
id: VISUALIZER_ID$7,
|
|
8624
8624
|
title: "Graph Traversal (Interview Mode)",
|
|
8625
|
-
badges: BADGES$
|
|
8625
|
+
badges: BADGES$y,
|
|
8626
8626
|
gradient: "blue",
|
|
8627
8627
|
className,
|
|
8628
8628
|
minHeight: 500,
|
|
@@ -8646,17 +8646,17 @@ const GraphInterviewVisualizerComponent = ({
|
|
|
8646
8646
|
accentColor: "blue"
|
|
8647
8647
|
},
|
|
8648
8648
|
showControls,
|
|
8649
|
-
legendItems: LEGEND_ITEMS$
|
|
8649
|
+
legendItems: LEGEND_ITEMS$y,
|
|
8650
8650
|
sidePanel,
|
|
8651
8651
|
children: visualization
|
|
8652
8652
|
}
|
|
8653
8653
|
);
|
|
8654
8654
|
};
|
|
8655
8655
|
const GraphInterviewVisualizer = React.memo(GraphInterviewVisualizerComponent);
|
|
8656
|
-
const VISUALIZER_ID$
|
|
8656
|
+
const VISUALIZER_ID$6 = "bloomfilter-interview-visualizer";
|
|
8657
8657
|
const BIT_ARRAY_SIZE$1 = 16;
|
|
8658
8658
|
const K_HASH_FUNCTIONS = 3;
|
|
8659
|
-
const BADGES$
|
|
8659
|
+
const BADGES$x = [
|
|
8660
8660
|
{ label: "Interview Mode", variant: "purple" },
|
|
8661
8661
|
{ label: "Probabilistic", variant: "pink" },
|
|
8662
8662
|
{ label: "No False Negatives", variant: "indigo" }
|
|
@@ -8669,7 +8669,7 @@ const OPERATIONS$i = [
|
|
|
8669
8669
|
{ op: "query", element: "grape" },
|
|
8670
8670
|
{ op: "query", element: "banana" }
|
|
8671
8671
|
];
|
|
8672
|
-
const LEGEND_ITEMS$
|
|
8672
|
+
const LEGEND_ITEMS$x = [
|
|
8673
8673
|
{ color: "bg-gray-200", label: "Bit = 0" },
|
|
8674
8674
|
{ color: "bg-purple-500", label: "Bit = 1" },
|
|
8675
8675
|
{ color: "bg-pink-400", label: "Current hash position" }
|
|
@@ -8878,7 +8878,7 @@ const BloomFilterInterviewVisualizerComponent = ({
|
|
|
8878
8878
|
showControls = true,
|
|
8879
8879
|
className = ""
|
|
8880
8880
|
}) => {
|
|
8881
|
-
const { copyUrlToClipboard } = useUrlState({ prefix: "bf-int", scrollToId: VISUALIZER_ID$
|
|
8881
|
+
const { copyUrlToClipboard } = useUrlState({ prefix: "bf-int", scrollToId: VISUALIZER_ID$6 });
|
|
8882
8882
|
const [mode, setMode] = React.useState("visualize");
|
|
8883
8883
|
const generateSteps = React.useMemo(() => generateBloomFilterSteps$1, []);
|
|
8884
8884
|
const {
|
|
@@ -8995,9 +8995,9 @@ const BloomFilterInterviewVisualizerComponent = ({
|
|
|
8995
8995
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
8996
8996
|
BaseVisualizerLayout,
|
|
8997
8997
|
{
|
|
8998
|
-
id: VISUALIZER_ID$
|
|
8998
|
+
id: VISUALIZER_ID$6,
|
|
8999
8999
|
title: "Bloom Filter (Interview Mode)",
|
|
9000
|
-
badges: BADGES$
|
|
9000
|
+
badges: BADGES$x,
|
|
9001
9001
|
gradient: "purple",
|
|
9002
9002
|
className,
|
|
9003
9003
|
minHeight: 500,
|
|
@@ -9022,16 +9022,16 @@ const BloomFilterInterviewVisualizerComponent = ({
|
|
|
9022
9022
|
accentColor: "purple"
|
|
9023
9023
|
},
|
|
9024
9024
|
showControls,
|
|
9025
|
-
legendItems: LEGEND_ITEMS$
|
|
9025
|
+
legendItems: LEGEND_ITEMS$x,
|
|
9026
9026
|
sidePanel,
|
|
9027
9027
|
children: visualization
|
|
9028
9028
|
}
|
|
9029
9029
|
);
|
|
9030
9030
|
};
|
|
9031
9031
|
const BloomFilterInterviewVisualizer = React.memo(BloomFilterInterviewVisualizerComponent);
|
|
9032
|
-
const VISUALIZER_ID$
|
|
9032
|
+
const VISUALIZER_ID$5 = "btree-interview-visualizer";
|
|
9033
9033
|
const ORDER$1 = 3;
|
|
9034
|
-
const BADGES$
|
|
9034
|
+
const BADGES$w = [
|
|
9035
9035
|
{ label: "Interview Mode", variant: "purple" },
|
|
9036
9036
|
{ label: `Order ${ORDER$1}`, variant: "green" },
|
|
9037
9037
|
{ label: "O(log n)", variant: "teal" }
|
|
@@ -9045,7 +9045,7 @@ const OPERATIONS$h = [
|
|
|
9045
9045
|
{ op: "search", value: 15 },
|
|
9046
9046
|
{ op: "search", value: 12 }
|
|
9047
9047
|
];
|
|
9048
|
-
const LEGEND_ITEMS$
|
|
9048
|
+
const LEGEND_ITEMS$w = [
|
|
9049
9049
|
{ color: "bg-green-400", label: "Current node" },
|
|
9050
9050
|
{ color: "bg-amber-100", label: "Search path", border: "#fbbf24" },
|
|
9051
9051
|
{ color: "bg-blue-400", label: "Found/Inserted" }
|
|
@@ -9311,7 +9311,7 @@ const BTreeInterviewVisualizerComponent = ({
|
|
|
9311
9311
|
showControls = true,
|
|
9312
9312
|
className = ""
|
|
9313
9313
|
}) => {
|
|
9314
|
-
const { copyUrlToClipboard } = useUrlState({ prefix: "bt-int", scrollToId: VISUALIZER_ID$
|
|
9314
|
+
const { copyUrlToClipboard } = useUrlState({ prefix: "bt-int", scrollToId: VISUALIZER_ID$5 });
|
|
9315
9315
|
const [mode, setMode] = React.useState("visualize");
|
|
9316
9316
|
const generateSteps = React.useMemo(() => generateBTreeSteps$1, []);
|
|
9317
9317
|
const {
|
|
@@ -9448,9 +9448,9 @@ const BTreeInterviewVisualizerComponent = ({
|
|
|
9448
9448
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
9449
9449
|
BaseVisualizerLayout,
|
|
9450
9450
|
{
|
|
9451
|
-
id: VISUALIZER_ID$
|
|
9451
|
+
id: VISUALIZER_ID$5,
|
|
9452
9452
|
title: "B-Tree (Interview Mode)",
|
|
9453
|
-
badges: BADGES$
|
|
9453
|
+
badges: BADGES$w,
|
|
9454
9454
|
gradient: "green",
|
|
9455
9455
|
className,
|
|
9456
9456
|
minHeight: 500,
|
|
@@ -9475,17 +9475,17 @@ const BTreeInterviewVisualizerComponent = ({
|
|
|
9475
9475
|
accentColor: "green"
|
|
9476
9476
|
},
|
|
9477
9477
|
showControls,
|
|
9478
|
-
legendItems: LEGEND_ITEMS$
|
|
9478
|
+
legendItems: LEGEND_ITEMS$w,
|
|
9479
9479
|
sidePanel,
|
|
9480
9480
|
children: visualization
|
|
9481
9481
|
}
|
|
9482
9482
|
);
|
|
9483
9483
|
};
|
|
9484
9484
|
const BTreeInterviewVisualizer = React.memo(BTreeInterviewVisualizerComponent);
|
|
9485
|
-
const BADGES$
|
|
9485
|
+
const BADGES$v = [
|
|
9486
9486
|
{ label: "O((V+E) log V)", variant: "orange" }
|
|
9487
9487
|
];
|
|
9488
|
-
const LEGEND_ITEMS$
|
|
9488
|
+
const LEGEND_ITEMS$v = [
|
|
9489
9489
|
{ color: "bg-blue-100", label: "Unvisited", border: "#60a5fa" },
|
|
9490
9490
|
{ color: "bg-amber-400", label: "Current" },
|
|
9491
9491
|
{ color: "bg-green-400", label: "Visited" }
|
|
@@ -9844,7 +9844,7 @@ const DijkstraInterviewVisualizerComponent = ({
|
|
|
9844
9844
|
{
|
|
9845
9845
|
id: VISUALIZER_ID2,
|
|
9846
9846
|
title: "Dijkstra's Algorithm (Interview Mode)",
|
|
9847
|
-
badges: BADGES$
|
|
9847
|
+
badges: BADGES$v,
|
|
9848
9848
|
gradient: "orange",
|
|
9849
9849
|
className,
|
|
9850
9850
|
minHeight: 500,
|
|
@@ -9869,17 +9869,17 @@ const DijkstraInterviewVisualizerComponent = ({
|
|
|
9869
9869
|
accentColor: "orange"
|
|
9870
9870
|
},
|
|
9871
9871
|
showControls,
|
|
9872
|
-
legendItems: LEGEND_ITEMS$
|
|
9872
|
+
legendItems: LEGEND_ITEMS$v,
|
|
9873
9873
|
sidePanel,
|
|
9874
9874
|
children: visualization
|
|
9875
9875
|
}
|
|
9876
9876
|
);
|
|
9877
9877
|
};
|
|
9878
9878
|
const DijkstraInterviewVisualizer = React.memo(DijkstraInterviewVisualizerComponent);
|
|
9879
|
-
const BADGES$
|
|
9879
|
+
const BADGES$u = [
|
|
9880
9880
|
{ label: "O(n×W)", variant: "cyan" }
|
|
9881
9881
|
];
|
|
9882
|
-
const LEGEND_ITEMS$
|
|
9882
|
+
const LEGEND_ITEMS$u = [
|
|
9883
9883
|
{ color: "bg-gray-50", label: "Not computed", border: "#d1d5db" },
|
|
9884
9884
|
{ color: "bg-blue-100", label: "Computed" },
|
|
9885
9885
|
{ color: "bg-green-400", label: "Take item" },
|
|
@@ -10236,7 +10236,7 @@ const DPInterviewVisualizerComponent = ({
|
|
|
10236
10236
|
{
|
|
10237
10237
|
id: VISUALIZER_ID2,
|
|
10238
10238
|
title: "0/1 Knapsack (DP)",
|
|
10239
|
-
badges: BADGES$
|
|
10239
|
+
badges: BADGES$u,
|
|
10240
10240
|
gradient: "cyan",
|
|
10241
10241
|
className,
|
|
10242
10242
|
minHeight: 400,
|
|
@@ -10261,17 +10261,17 @@ const DPInterviewVisualizerComponent = ({
|
|
|
10261
10261
|
accentColor: "cyan"
|
|
10262
10262
|
},
|
|
10263
10263
|
showControls,
|
|
10264
|
-
legendItems: LEGEND_ITEMS$
|
|
10264
|
+
legendItems: LEGEND_ITEMS$u,
|
|
10265
10265
|
sidePanel,
|
|
10266
10266
|
children: visualization
|
|
10267
10267
|
}
|
|
10268
10268
|
);
|
|
10269
10269
|
};
|
|
10270
10270
|
const DPInterviewVisualizer = React.memo(DPInterviewVisualizerComponent);
|
|
10271
|
-
const BADGES$
|
|
10271
|
+
const BADGES$t = [
|
|
10272
10272
|
{ label: "Distributed Systems", variant: "cyan" }
|
|
10273
10273
|
];
|
|
10274
|
-
const LEGEND_ITEMS$
|
|
10274
|
+
const LEGEND_ITEMS$t = [
|
|
10275
10275
|
{ color: "bg-blue-500", label: "Server A" },
|
|
10276
10276
|
{ color: "bg-green-500", label: "Server B" },
|
|
10277
10277
|
{ color: "bg-purple-500", label: "Server C" },
|
|
@@ -10684,7 +10684,7 @@ const ConsistentHashingInterviewVisualizerComponent = ({
|
|
|
10684
10684
|
{
|
|
10685
10685
|
id: VISUALIZER_ID2,
|
|
10686
10686
|
title: "Consistent Hashing (Interview Mode)",
|
|
10687
|
-
badges: BADGES$
|
|
10687
|
+
badges: BADGES$t,
|
|
10688
10688
|
gradient: "cyan",
|
|
10689
10689
|
className,
|
|
10690
10690
|
minHeight: 500,
|
|
@@ -10709,17 +10709,17 @@ const ConsistentHashingInterviewVisualizerComponent = ({
|
|
|
10709
10709
|
accentColor: "cyan"
|
|
10710
10710
|
},
|
|
10711
10711
|
showControls,
|
|
10712
|
-
legendItems: LEGEND_ITEMS$
|
|
10712
|
+
legendItems: LEGEND_ITEMS$t,
|
|
10713
10713
|
sidePanel,
|
|
10714
10714
|
children: visualization
|
|
10715
10715
|
}
|
|
10716
10716
|
);
|
|
10717
10717
|
};
|
|
10718
10718
|
const ConsistentHashingInterviewVisualizer = React.memo(ConsistentHashingInterviewVisualizerComponent);
|
|
10719
|
-
const BADGES$
|
|
10719
|
+
const BADGES$s = [
|
|
10720
10720
|
{ label: "Distributed Consensus", variant: "orange" }
|
|
10721
10721
|
];
|
|
10722
|
-
const LEGEND_ITEMS$
|
|
10722
|
+
const LEGEND_ITEMS$s = [
|
|
10723
10723
|
{ color: "bg-gray-400", label: "Follower" },
|
|
10724
10724
|
{ color: "bg-amber-500", label: "Candidate" },
|
|
10725
10725
|
{ color: "bg-green-500", label: "Leader" },
|
|
@@ -11149,7 +11149,7 @@ const RaftInterviewVisualizerComponent = ({
|
|
|
11149
11149
|
{
|
|
11150
11150
|
id: VISUALIZER_ID2,
|
|
11151
11151
|
title: "Raft Consensus",
|
|
11152
|
-
badges: BADGES$
|
|
11152
|
+
badges: BADGES$s,
|
|
11153
11153
|
gradient: "orange",
|
|
11154
11154
|
className,
|
|
11155
11155
|
minHeight: 400,
|
|
@@ -11174,15 +11174,15 @@ const RaftInterviewVisualizerComponent = ({
|
|
|
11174
11174
|
accentColor: "orange"
|
|
11175
11175
|
},
|
|
11176
11176
|
showControls,
|
|
11177
|
-
legendItems: LEGEND_ITEMS$
|
|
11177
|
+
legendItems: LEGEND_ITEMS$s,
|
|
11178
11178
|
sidePanel,
|
|
11179
11179
|
children: visualization
|
|
11180
11180
|
}
|
|
11181
11181
|
);
|
|
11182
11182
|
};
|
|
11183
11183
|
const RaftInterviewVisualizer = React.memo(RaftInterviewVisualizerComponent);
|
|
11184
|
-
const VISUALIZER_ID$
|
|
11185
|
-
const BADGES$
|
|
11184
|
+
const VISUALIZER_ID$4 = "trie-interview-visualizer";
|
|
11185
|
+
const BADGES$r = [
|
|
11186
11186
|
{ label: "O(m) ops", variant: "cyan" }
|
|
11187
11187
|
];
|
|
11188
11188
|
const OPERATIONS$g = [
|
|
@@ -11194,7 +11194,7 @@ const OPERATIONS$g = [
|
|
|
11194
11194
|
{ op: "search", word: "car" },
|
|
11195
11195
|
{ op: "prefix", word: "car" }
|
|
11196
11196
|
];
|
|
11197
|
-
const LEGEND_ITEMS$
|
|
11197
|
+
const LEGEND_ITEMS$r = [
|
|
11198
11198
|
{ color: "bg-gray-100", label: "Node", border: "#d1d5db" },
|
|
11199
11199
|
{ color: "bg-blue-200", label: "Current", border: "#60a5fa" },
|
|
11200
11200
|
{ color: "bg-green-400", label: "End of word" },
|
|
@@ -11529,7 +11529,7 @@ const TrieInterviewVisualizerComponent = ({
|
|
|
11529
11529
|
showControls = true,
|
|
11530
11530
|
className = ""
|
|
11531
11531
|
}) => {
|
|
11532
|
-
const { copyUrlToClipboard } = useUrlState({ prefix: "trie-int", scrollToId: VISUALIZER_ID$
|
|
11532
|
+
const { copyUrlToClipboard } = useUrlState({ prefix: "trie-int", scrollToId: VISUALIZER_ID$4 });
|
|
11533
11533
|
const [mode, setMode] = React.useState("visualize");
|
|
11534
11534
|
const generateSteps = React.useMemo(() => generateTrieSteps$1, []);
|
|
11535
11535
|
const playback = useVisualizerPlayback({ generateSteps });
|
|
@@ -11608,9 +11608,9 @@ const TrieInterviewVisualizerComponent = ({
|
|
|
11608
11608
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
11609
11609
|
BaseVisualizerLayout,
|
|
11610
11610
|
{
|
|
11611
|
-
id: VISUALIZER_ID$
|
|
11611
|
+
id: VISUALIZER_ID$4,
|
|
11612
11612
|
title: "Trie (Prefix Tree) - Interview Mode",
|
|
11613
|
-
badges: BADGES$
|
|
11613
|
+
badges: BADGES$r,
|
|
11614
11614
|
gradient: "cyan",
|
|
11615
11615
|
className,
|
|
11616
11616
|
minHeight: 500,
|
|
@@ -11635,16 +11635,16 @@ const TrieInterviewVisualizerComponent = ({
|
|
|
11635
11635
|
accentColor: "cyan"
|
|
11636
11636
|
},
|
|
11637
11637
|
showControls,
|
|
11638
|
-
legendItems: LEGEND_ITEMS$
|
|
11638
|
+
legendItems: LEGEND_ITEMS$r,
|
|
11639
11639
|
sidePanel,
|
|
11640
11640
|
children: visualization
|
|
11641
11641
|
}
|
|
11642
11642
|
);
|
|
11643
11643
|
};
|
|
11644
11644
|
const TrieInterviewVisualizer = React.memo(TrieInterviewVisualizerComponent);
|
|
11645
|
-
const VISUALIZER_ID$
|
|
11645
|
+
const VISUALIZER_ID$3 = "unionfind-interview-visualizer";
|
|
11646
11646
|
const INITIAL_SIZE$2 = 8;
|
|
11647
|
-
const BADGES$
|
|
11647
|
+
const BADGES$q = [
|
|
11648
11648
|
{ label: "O(α(n))", variant: "purple" }
|
|
11649
11649
|
];
|
|
11650
11650
|
const OPERATIONS$f = [
|
|
@@ -11657,7 +11657,7 @@ const OPERATIONS$f = [
|
|
|
11657
11657
|
{ op: "connected", a: 1, b: 3 },
|
|
11658
11658
|
{ op: "union", a: 0, b: 4 }
|
|
11659
11659
|
];
|
|
11660
|
-
const LEGEND_ITEMS$
|
|
11660
|
+
const LEGEND_ITEMS$q = [
|
|
11661
11661
|
{ color: "bg-gray-100", label: "Element", border: "#d1d5db" },
|
|
11662
11662
|
{ color: "bg-blue-200", label: "Current", border: "#60a5fa" },
|
|
11663
11663
|
{ color: "bg-green-400", label: "Root / Same set" }
|
|
@@ -11886,7 +11886,7 @@ const UnionFindInterviewVisualizerComponent = ({
|
|
|
11886
11886
|
showControls = true,
|
|
11887
11887
|
className = ""
|
|
11888
11888
|
}) => {
|
|
11889
|
-
const { copyUrlToClipboard } = useUrlState({ prefix: "uf-int", scrollToId: VISUALIZER_ID$
|
|
11889
|
+
const { copyUrlToClipboard } = useUrlState({ prefix: "uf-int", scrollToId: VISUALIZER_ID$3 });
|
|
11890
11890
|
const [mode, setMode] = React.useState("visualize");
|
|
11891
11891
|
const generateSteps = React.useMemo(() => generateUnionFindSteps$1, []);
|
|
11892
11892
|
const playback = useVisualizerPlayback({ generateSteps });
|
|
@@ -12009,9 +12009,9 @@ const UnionFindInterviewVisualizerComponent = ({
|
|
|
12009
12009
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12010
12010
|
BaseVisualizerLayout,
|
|
12011
12011
|
{
|
|
12012
|
-
id: VISUALIZER_ID$
|
|
12012
|
+
id: VISUALIZER_ID$3,
|
|
12013
12013
|
title: "Union-Find (DSU) - Interview Mode",
|
|
12014
|
-
badges: BADGES$
|
|
12014
|
+
badges: BADGES$q,
|
|
12015
12015
|
gradient: "purple",
|
|
12016
12016
|
className,
|
|
12017
12017
|
minHeight: 500,
|
|
@@ -12036,14 +12036,14 @@ const UnionFindInterviewVisualizerComponent = ({
|
|
|
12036
12036
|
accentColor: "purple"
|
|
12037
12037
|
},
|
|
12038
12038
|
showControls,
|
|
12039
|
-
legendItems: LEGEND_ITEMS$
|
|
12039
|
+
legendItems: LEGEND_ITEMS$q,
|
|
12040
12040
|
sidePanel,
|
|
12041
12041
|
children: visualization
|
|
12042
12042
|
}
|
|
12043
12043
|
);
|
|
12044
12044
|
};
|
|
12045
12045
|
const UnionFindInterviewVisualizer = React.memo(UnionFindInterviewVisualizerComponent);
|
|
12046
|
-
const VISUALIZER_ID$
|
|
12046
|
+
const VISUALIZER_ID$2 = "astar-interview-visualizer";
|
|
12047
12047
|
const GRID_ROWS = 6;
|
|
12048
12048
|
const GRID_COLS = 8;
|
|
12049
12049
|
const START = { row: 1, col: 1 };
|
|
@@ -12055,12 +12055,12 @@ const WALLS = [
|
|
|
12055
12055
|
{ row: 3, col: 5 },
|
|
12056
12056
|
{ row: 4, col: 5 }
|
|
12057
12057
|
];
|
|
12058
|
-
const BADGES$
|
|
12058
|
+
const BADGES$p = [
|
|
12059
12059
|
{ label: "Interview Mode", variant: "purple" },
|
|
12060
12060
|
{ label: "f = g + h", variant: "amber" },
|
|
12061
12061
|
{ label: "O(b^d)", variant: "orange" }
|
|
12062
12062
|
];
|
|
12063
|
-
const LEGEND_ITEMS$
|
|
12063
|
+
const LEGEND_ITEMS$p = [
|
|
12064
12064
|
{ color: "bg-green-500", label: "Start" },
|
|
12065
12065
|
{ color: "bg-red-500", label: "End" },
|
|
12066
12066
|
{ color: "bg-gray-700", label: "Wall" },
|
|
@@ -12314,7 +12314,7 @@ const AStarInterviewVisualizerComponent = ({
|
|
|
12314
12314
|
showControls = true,
|
|
12315
12315
|
className = ""
|
|
12316
12316
|
}) => {
|
|
12317
|
-
const { copyUrlToClipboard } = useUrlState({ prefix: "astar-int", scrollToId: VISUALIZER_ID$
|
|
12317
|
+
const { copyUrlToClipboard } = useUrlState({ prefix: "astar-int", scrollToId: VISUALIZER_ID$2 });
|
|
12318
12318
|
const [mode, setMode] = React.useState("visualize");
|
|
12319
12319
|
const generateSteps = React.useMemo(() => generateAStarSteps, []);
|
|
12320
12320
|
const {
|
|
@@ -12417,9 +12417,9 @@ const AStarInterviewVisualizerComponent = ({
|
|
|
12417
12417
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12418
12418
|
BaseVisualizerLayout,
|
|
12419
12419
|
{
|
|
12420
|
-
id: VISUALIZER_ID$
|
|
12420
|
+
id: VISUALIZER_ID$2,
|
|
12421
12421
|
title: "A* Pathfinding (Interview Mode)",
|
|
12422
|
-
badges: BADGES$
|
|
12422
|
+
badges: BADGES$p,
|
|
12423
12423
|
gradient: "orange",
|
|
12424
12424
|
className,
|
|
12425
12425
|
minHeight: 500,
|
|
@@ -12444,14 +12444,14 @@ const AStarInterviewVisualizerComponent = ({
|
|
|
12444
12444
|
accentColor: "orange"
|
|
12445
12445
|
},
|
|
12446
12446
|
showControls,
|
|
12447
|
-
legendItems: LEGEND_ITEMS$
|
|
12447
|
+
legendItems: LEGEND_ITEMS$p,
|
|
12448
12448
|
sidePanel,
|
|
12449
12449
|
children: visualization
|
|
12450
12450
|
}
|
|
12451
12451
|
);
|
|
12452
12452
|
};
|
|
12453
12453
|
const AStarInterviewVisualizer = React.memo(AStarInterviewVisualizerComponent);
|
|
12454
|
-
const BADGES$
|
|
12454
|
+
const BADGES$o = [
|
|
12455
12455
|
{ label: "O(log n) avg", variant: "indigo" }
|
|
12456
12456
|
];
|
|
12457
12457
|
const INITIAL_NODES = [
|
|
@@ -12462,7 +12462,7 @@ const INITIAL_NODES = [
|
|
|
12462
12462
|
{ value: 9, levels: 2 },
|
|
12463
12463
|
{ value: 12, levels: 1 }
|
|
12464
12464
|
];
|
|
12465
|
-
const LEGEND_ITEMS$
|
|
12465
|
+
const LEGEND_ITEMS$o = [
|
|
12466
12466
|
{ color: "bg-blue-100", label: "Node", border: "#60a5fa" },
|
|
12467
12467
|
{ color: "bg-amber-400", label: "Current" },
|
|
12468
12468
|
{ color: "bg-green-400", label: "Found" }
|
|
@@ -12748,7 +12748,7 @@ const SkipListInterviewVisualizerComponent = ({
|
|
|
12748
12748
|
{
|
|
12749
12749
|
id: VISUALIZER_ID2,
|
|
12750
12750
|
title: "Skip List",
|
|
12751
|
-
badges: BADGES$
|
|
12751
|
+
badges: BADGES$o,
|
|
12752
12752
|
gradient: "indigo",
|
|
12753
12753
|
className,
|
|
12754
12754
|
minHeight: 260,
|
|
@@ -12773,21 +12773,21 @@ const SkipListInterviewVisualizerComponent = ({
|
|
|
12773
12773
|
accentColor: "indigo"
|
|
12774
12774
|
},
|
|
12775
12775
|
showControls,
|
|
12776
|
-
legendItems: LEGEND_ITEMS$
|
|
12776
|
+
legendItems: LEGEND_ITEMS$o,
|
|
12777
12777
|
sidePanel,
|
|
12778
12778
|
children: visualization
|
|
12779
12779
|
}
|
|
12780
12780
|
);
|
|
12781
12781
|
};
|
|
12782
12782
|
const SkipListInterviewVisualizer = React.memo(SkipListInterviewVisualizerComponent);
|
|
12783
|
-
const VISUALIZER_ID = "linkedlist-interview-visualizer";
|
|
12784
|
-
const BADGES$
|
|
12783
|
+
const VISUALIZER_ID$1 = "linkedlist-interview-visualizer";
|
|
12784
|
+
const BADGES$n = [
|
|
12785
12785
|
{ label: "Interview Mode", variant: "purple" },
|
|
12786
12786
|
{ label: "O(1) insert", variant: "blue" },
|
|
12787
12787
|
{ label: "Linked List", variant: "cyan" }
|
|
12788
12788
|
];
|
|
12789
12789
|
const INITIAL_VALUES = [10, 20, 30, 40, 50];
|
|
12790
|
-
const LEGEND_ITEMS$
|
|
12790
|
+
const LEGEND_ITEMS$n = [
|
|
12791
12791
|
{ color: "bg-blue-100", label: "Node", border: "#60a5fa" },
|
|
12792
12792
|
{ color: "bg-yellow-400", label: "Current" },
|
|
12793
12793
|
{ color: "bg-green-400", label: "Head" },
|
|
@@ -12959,7 +12959,7 @@ const LinkedListInterviewVisualizerComponent = ({
|
|
|
12959
12959
|
showControls = true,
|
|
12960
12960
|
className = ""
|
|
12961
12961
|
}) => {
|
|
12962
|
-
const { copyUrlToClipboard } = useUrlState({ prefix: "ll-int", scrollToId: VISUALIZER_ID });
|
|
12962
|
+
const { copyUrlToClipboard } = useUrlState({ prefix: "ll-int", scrollToId: VISUALIZER_ID$1 });
|
|
12963
12963
|
const [mode, setMode] = React.useState("visualize");
|
|
12964
12964
|
const generateSteps = React.useMemo(() => generateLinkedListSteps$1, []);
|
|
12965
12965
|
const {
|
|
@@ -13046,9 +13046,9 @@ const LinkedListInterviewVisualizerComponent = ({
|
|
|
13046
13046
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
13047
13047
|
BaseVisualizerLayout,
|
|
13048
13048
|
{
|
|
13049
|
-
id: VISUALIZER_ID,
|
|
13049
|
+
id: VISUALIZER_ID$1,
|
|
13050
13050
|
title: "Linked List (Interview Mode)",
|
|
13051
|
-
badges: BADGES$
|
|
13051
|
+
badges: BADGES$n,
|
|
13052
13052
|
gradient: "blue",
|
|
13053
13053
|
className,
|
|
13054
13054
|
minHeight: 400,
|
|
@@ -13072,7 +13072,7 @@ const LinkedListInterviewVisualizerComponent = ({
|
|
|
13072
13072
|
accentColor: "blue"
|
|
13073
13073
|
},
|
|
13074
13074
|
showControls,
|
|
13075
|
-
legendItems: LEGEND_ITEMS$
|
|
13075
|
+
legendItems: LEGEND_ITEMS$n,
|
|
13076
13076
|
sidePanel,
|
|
13077
13077
|
children: visualization
|
|
13078
13078
|
}
|
|
@@ -13100,13 +13100,13 @@ const HASH_TABLE_CODE = [
|
|
|
13100
13100
|
" if loadFactor > threshold:",
|
|
13101
13101
|
" rehash(newSize = size * 2)"
|
|
13102
13102
|
];
|
|
13103
|
-
const LEGEND_ITEMS$
|
|
13103
|
+
const LEGEND_ITEMS$m = [
|
|
13104
13104
|
{ color: "bg-gray-50", label: "Empty", border: "#d1d5db" },
|
|
13105
13105
|
{ color: "bg-yellow-50", label: "Hashing", border: "#facc15" },
|
|
13106
13106
|
{ color: "bg-red-50", label: "Collision", border: "#f87171" },
|
|
13107
13107
|
{ color: "bg-green-50", label: "Placed", border: "#4ade80" }
|
|
13108
13108
|
];
|
|
13109
|
-
const BADGES$
|
|
13109
|
+
const BADGES$m = [
|
|
13110
13110
|
{ label: "Avg: O(1)", variant: "purple" },
|
|
13111
13111
|
{ label: "Worst: O(n)", variant: "purple" }
|
|
13112
13112
|
];
|
|
@@ -13421,7 +13421,7 @@ const HashTableVisualizerComponent = ({
|
|
|
13421
13421
|
{
|
|
13422
13422
|
id: "hashtable-visualizer",
|
|
13423
13423
|
title: "Hash Table (Chaining)",
|
|
13424
|
-
badges: BADGES$
|
|
13424
|
+
badges: BADGES$m,
|
|
13425
13425
|
gradient: "purple",
|
|
13426
13426
|
className,
|
|
13427
13427
|
minHeight: 400,
|
|
@@ -13445,7 +13445,7 @@ const HashTableVisualizerComponent = ({
|
|
|
13445
13445
|
extraControls
|
|
13446
13446
|
},
|
|
13447
13447
|
showControls,
|
|
13448
|
-
legendItems: LEGEND_ITEMS$
|
|
13448
|
+
legendItems: LEGEND_ITEMS$m,
|
|
13449
13449
|
code: showCode ? HASH_TABLE_CODE : void 0,
|
|
13450
13450
|
currentCodeLine: stepData == null ? void 0 : stepData.codeLine,
|
|
13451
13451
|
codeVariables: stepData == null ? void 0 : stepData.variables,
|
|
@@ -13487,11 +13487,11 @@ const LINKEDLIST_CODE = [
|
|
|
13487
13487
|
" node = node.next",
|
|
13488
13488
|
" return node.value"
|
|
13489
13489
|
];
|
|
13490
|
-
const LEGEND_ITEMS$
|
|
13490
|
+
const LEGEND_ITEMS$l = [
|
|
13491
13491
|
{ color: "bg-white", label: "Node", border: "#d1d5db" },
|
|
13492
13492
|
{ color: "bg-blue-500", label: "Active" }
|
|
13493
13493
|
];
|
|
13494
|
-
const BADGES$
|
|
13494
|
+
const BADGES$l = [
|
|
13495
13495
|
{ label: "Ends: O(1)", variant: "blue" },
|
|
13496
13496
|
{ label: "Index: O(n)", variant: "indigo" }
|
|
13497
13497
|
];
|
|
@@ -13689,7 +13689,7 @@ const LinkedListVisualizerComponent = ({
|
|
|
13689
13689
|
{
|
|
13690
13690
|
id: VISUALIZER_ID2,
|
|
13691
13691
|
title: "LinkedList Operations",
|
|
13692
|
-
badges: BADGES$
|
|
13692
|
+
badges: BADGES$l,
|
|
13693
13693
|
gradient: "blue",
|
|
13694
13694
|
onShare: handleShare,
|
|
13695
13695
|
className,
|
|
@@ -13713,7 +13713,7 @@ const LinkedListVisualizerComponent = ({
|
|
|
13713
13713
|
accentColor: "blue"
|
|
13714
13714
|
},
|
|
13715
13715
|
showControls,
|
|
13716
|
-
legendItems: LEGEND_ITEMS$
|
|
13716
|
+
legendItems: LEGEND_ITEMS$l,
|
|
13717
13717
|
code: showCode ? LINKEDLIST_CODE : void 0,
|
|
13718
13718
|
currentCodeLine: currentStepData == null ? void 0 : currentStepData.codeLine,
|
|
13719
13719
|
codeVariables: currentStepData == null ? void 0 : currentStepData.variables,
|
|
@@ -13760,13 +13760,13 @@ const LINKEDHASHMAP_CODE = [
|
|
|
13760
13760
|
" }",
|
|
13761
13761
|
"}"
|
|
13762
13762
|
];
|
|
13763
|
-
const LEGEND_ITEMS$
|
|
13763
|
+
const LEGEND_ITEMS$k = [
|
|
13764
13764
|
{ color: "bg-blue-50", label: "Current bucket", border: "#60a5fa" },
|
|
13765
13765
|
{ color: "bg-blue-500", label: "Insert/Update" },
|
|
13766
13766
|
{ color: "bg-green-400", label: "Found" },
|
|
13767
13767
|
{ color: "bg-orange-400", label: "Linked list order" }
|
|
13768
13768
|
];
|
|
13769
|
-
const BADGES$
|
|
13769
|
+
const BADGES$k = [
|
|
13770
13770
|
{ label: "O(1) ops", variant: "orange" },
|
|
13771
13771
|
{ label: "Ordered", variant: "amber" }
|
|
13772
13772
|
];
|
|
@@ -14178,7 +14178,7 @@ const LinkedHashMapVisualizerComponent = ({
|
|
|
14178
14178
|
{
|
|
14179
14179
|
id: VISUALIZER_ID2,
|
|
14180
14180
|
title: "LinkedHashMap",
|
|
14181
|
-
badges: BADGES$
|
|
14181
|
+
badges: BADGES$k,
|
|
14182
14182
|
gradient: "orange",
|
|
14183
14183
|
onShare: handleShare,
|
|
14184
14184
|
className,
|
|
@@ -14203,7 +14203,7 @@ const LinkedHashMapVisualizerComponent = ({
|
|
|
14203
14203
|
accentColor: "orange"
|
|
14204
14204
|
},
|
|
14205
14205
|
showControls,
|
|
14206
|
-
legendItems: LEGEND_ITEMS$
|
|
14206
|
+
legendItems: LEGEND_ITEMS$k,
|
|
14207
14207
|
code: showCode ? LINKEDHASHMAP_CODE : void 0,
|
|
14208
14208
|
currentCodeLine: currentStepData == null ? void 0 : currentStepData.codeLine,
|
|
14209
14209
|
codeVariables: currentStepData == null ? void 0 : currentStepData.variables,
|
|
@@ -14244,13 +14244,13 @@ const ARRAYLIST_CODE = [
|
|
|
14244
14244
|
" shift elements left",
|
|
14245
14245
|
" size--"
|
|
14246
14246
|
];
|
|
14247
|
-
const LEGEND_ITEMS$
|
|
14247
|
+
const LEGEND_ITEMS$j = [
|
|
14248
14248
|
{ color: "bg-white border-gray-300", label: "Used", border: "#d1d5db" },
|
|
14249
14249
|
{ color: "bg-gray-100", label: "Empty" },
|
|
14250
14250
|
{ color: "bg-orange-500", label: "Active" },
|
|
14251
14251
|
{ color: "bg-yellow-200", label: "Shifted", border: "#fbbf24" }
|
|
14252
14252
|
];
|
|
14253
|
-
const BADGES$
|
|
14253
|
+
const BADGES$j = [
|
|
14254
14254
|
{ label: "Get: O(1)", variant: "orange" },
|
|
14255
14255
|
{ label: "Add: O(1)*", variant: "amber" }
|
|
14256
14256
|
];
|
|
@@ -14538,7 +14538,7 @@ const ArrayListVisualizerComponent = ({
|
|
|
14538
14538
|
{
|
|
14539
14539
|
id: VISUALIZER_ID2,
|
|
14540
14540
|
title: "ArrayList Operations",
|
|
14541
|
-
badges: BADGES$
|
|
14541
|
+
badges: BADGES$j,
|
|
14542
14542
|
gradient: "orange",
|
|
14543
14543
|
onShare: handleShare,
|
|
14544
14544
|
className,
|
|
@@ -14562,7 +14562,7 @@ const ArrayListVisualizerComponent = ({
|
|
|
14562
14562
|
accentColor: "orange"
|
|
14563
14563
|
},
|
|
14564
14564
|
showControls,
|
|
14565
|
-
legendItems: LEGEND_ITEMS$
|
|
14565
|
+
legendItems: LEGEND_ITEMS$j,
|
|
14566
14566
|
code: showCode ? ARRAYLIST_CODE : void 0,
|
|
14567
14567
|
currentCodeLine: currentStepData == null ? void 0 : currentStepData.codeLine,
|
|
14568
14568
|
codeVariables: currentStepData == null ? void 0 : currentStepData.variables,
|
|
@@ -14619,14 +14619,14 @@ const ARRAYDEQUE_CODE = [
|
|
|
14619
14619
|
" }",
|
|
14620
14620
|
"}"
|
|
14621
14621
|
];
|
|
14622
|
-
const LEGEND_ITEMS$
|
|
14622
|
+
const LEGEND_ITEMS$i = [
|
|
14623
14623
|
{ color: "bg-teal-500", label: "Head pointer" },
|
|
14624
14624
|
{ color: "bg-violet-500", label: "Tail pointer" },
|
|
14625
14625
|
{ color: "bg-green-400", label: "Added element" },
|
|
14626
14626
|
{ color: "bg-red-400", label: "Removed element" },
|
|
14627
14627
|
{ color: "bg-yellow-200", label: "Resize" }
|
|
14628
14628
|
];
|
|
14629
|
-
const BADGES$
|
|
14629
|
+
const BADGES$i = [
|
|
14630
14630
|
{ label: "O(1) all ops", variant: "teal" },
|
|
14631
14631
|
{ label: "Circular buffer", variant: "purple" }
|
|
14632
14632
|
];
|
|
@@ -14978,7 +14978,7 @@ const ArrayDequeVisualizerComponent = ({
|
|
|
14978
14978
|
{
|
|
14979
14979
|
id: VISUALIZER_ID2,
|
|
14980
14980
|
title: "ArrayDeque",
|
|
14981
|
-
badges: BADGES$
|
|
14981
|
+
badges: BADGES$i,
|
|
14982
14982
|
gradient: "teal",
|
|
14983
14983
|
onShare: handleShare,
|
|
14984
14984
|
className,
|
|
@@ -15003,7 +15003,7 @@ const ArrayDequeVisualizerComponent = ({
|
|
|
15003
15003
|
accentColor: "teal"
|
|
15004
15004
|
},
|
|
15005
15005
|
showControls,
|
|
15006
|
-
legendItems: LEGEND_ITEMS$
|
|
15006
|
+
legendItems: LEGEND_ITEMS$i,
|
|
15007
15007
|
code: showCode ? ARRAYDEQUE_CODE : void 0,
|
|
15008
15008
|
currentCodeLine: currentStepData == null ? void 0 : currentStepData.codeLine,
|
|
15009
15009
|
codeVariables: currentStepData == null ? void 0 : currentStepData.variables,
|
|
@@ -15044,13 +15044,13 @@ const TREESET_CODE = [
|
|
|
15044
15044
|
" node = node.right",
|
|
15045
15045
|
" else: return // duplicate"
|
|
15046
15046
|
];
|
|
15047
|
-
const LEGEND_ITEMS$
|
|
15047
|
+
const LEGEND_ITEMS$h = [
|
|
15048
15048
|
{ color: "bg-yellow-100", label: "Path", border: "#facc15" },
|
|
15049
15049
|
{ color: "bg-blue-500", label: "Current/Insert" },
|
|
15050
15050
|
{ color: "bg-green-500", label: "Found" },
|
|
15051
15051
|
{ color: "bg-red-500", label: "Not found" }
|
|
15052
15052
|
];
|
|
15053
|
-
const BADGES$
|
|
15053
|
+
const BADGES$h = [
|
|
15054
15054
|
{ label: "Avg: O(log n)", variant: "green" },
|
|
15055
15055
|
{ label: "Worst: O(n)", variant: "amber" }
|
|
15056
15056
|
];
|
|
@@ -15416,7 +15416,7 @@ const TreeSetVisualizerComponent = ({
|
|
|
15416
15416
|
{
|
|
15417
15417
|
id: VISUALIZER_ID2,
|
|
15418
15418
|
title: "TreeSet Operations (BST)",
|
|
15419
|
-
badges: BADGES$
|
|
15419
|
+
badges: BADGES$h,
|
|
15420
15420
|
gradient: "green",
|
|
15421
15421
|
className,
|
|
15422
15422
|
minHeight: 400,
|
|
@@ -15440,7 +15440,7 @@ const TreeSetVisualizerComponent = ({
|
|
|
15440
15440
|
accentColor: "green"
|
|
15441
15441
|
},
|
|
15442
15442
|
showControls,
|
|
15443
|
-
legendItems: LEGEND_ITEMS$
|
|
15443
|
+
legendItems: LEGEND_ITEMS$h,
|
|
15444
15444
|
code: showCode ? TREESET_CODE : void 0,
|
|
15445
15445
|
currentCodeLine: currentStepData == null ? void 0 : currentStepData.codeLine,
|
|
15446
15446
|
codeVariables: currentStepData == null ? void 0 : currentStepData.variables,
|
|
@@ -15492,13 +15492,13 @@ const ENUMSET_CODE = [
|
|
|
15492
15492
|
" }",
|
|
15493
15493
|
"}"
|
|
15494
15494
|
];
|
|
15495
|
-
const LEGEND_ITEMS$
|
|
15495
|
+
const LEGEND_ITEMS$g = [
|
|
15496
15496
|
{ color: "bg-green-500", label: "Bit set (1)" },
|
|
15497
15497
|
{ color: "bg-gray-200", label: "Bit clear (0)" },
|
|
15498
15498
|
{ color: "bg-blue-500", label: "Current operation" },
|
|
15499
15499
|
{ color: "bg-yellow-400", label: "Changed bit" }
|
|
15500
15500
|
];
|
|
15501
|
-
const BADGES$
|
|
15501
|
+
const BADGES$g = [
|
|
15502
15502
|
{ label: "O(1) all ops", variant: "green" },
|
|
15503
15503
|
{ label: "Memory efficient", variant: "green" }
|
|
15504
15504
|
];
|
|
@@ -15767,7 +15767,7 @@ const EnumSetVisualizerComponent = ({
|
|
|
15767
15767
|
{
|
|
15768
15768
|
id: VISUALIZER_ID2,
|
|
15769
15769
|
title: "EnumSet Bit Operations",
|
|
15770
|
-
badges: BADGES$
|
|
15770
|
+
badges: BADGES$g,
|
|
15771
15771
|
gradient: "green",
|
|
15772
15772
|
onShare: handleShare,
|
|
15773
15773
|
className,
|
|
@@ -15792,7 +15792,7 @@ const EnumSetVisualizerComponent = ({
|
|
|
15792
15792
|
accentColor: "green"
|
|
15793
15793
|
},
|
|
15794
15794
|
showControls,
|
|
15795
|
-
legendItems: LEGEND_ITEMS$
|
|
15795
|
+
legendItems: LEGEND_ITEMS$g,
|
|
15796
15796
|
code: showCode ? ENUMSET_CODE : void 0,
|
|
15797
15797
|
currentCodeLine: currentStepData == null ? void 0 : currentStepData.codeLine,
|
|
15798
15798
|
codeVariables: currentStepData == null ? void 0 : currentStepData.variables,
|
|
@@ -15813,7 +15813,7 @@ const OPERATIONS$8 = [
|
|
|
15813
15813
|
{ op: "poll" },
|
|
15814
15814
|
{ op: "offer", value: 15 }
|
|
15815
15815
|
];
|
|
15816
|
-
const HEAP_CODE = [
|
|
15816
|
+
const HEAP_CODE$1 = [
|
|
15817
15817
|
"offer(value):",
|
|
15818
15818
|
" heap.add(value)",
|
|
15819
15819
|
" siftUp(size - 1)",
|
|
@@ -15831,18 +15831,18 @@ const HEAP_CODE = [
|
|
|
15831
15831
|
" siftDown(0)",
|
|
15832
15832
|
" return result"
|
|
15833
15833
|
];
|
|
15834
|
-
const LEGEND_ITEMS$
|
|
15834
|
+
const LEGEND_ITEMS$f = [
|
|
15835
15835
|
{ color: "bg-purple-100", label: "Root (min)", border: "#c4b5fd" },
|
|
15836
15836
|
{ color: "bg-purple-500", label: "Active" },
|
|
15837
15837
|
{ color: "bg-purple-200", label: "Sift Path", border: "#a78bfa" },
|
|
15838
15838
|
{ color: "bg-yellow-300", label: "Comparing" },
|
|
15839
15839
|
{ color: "bg-green-400", label: "Swapped" }
|
|
15840
15840
|
];
|
|
15841
|
-
const BADGES$
|
|
15841
|
+
const BADGES$f = [
|
|
15842
15842
|
{ label: "offer: O(log n)", variant: "purple" },
|
|
15843
15843
|
{ label: "poll: O(log n)", variant: "purple" }
|
|
15844
15844
|
];
|
|
15845
|
-
function generateHeapSteps() {
|
|
15845
|
+
function generateHeapSteps$1() {
|
|
15846
15846
|
const steps = [];
|
|
15847
15847
|
const heap = [];
|
|
15848
15848
|
steps.push({
|
|
@@ -16024,7 +16024,7 @@ function generateHeapSteps() {
|
|
|
16024
16024
|
});
|
|
16025
16025
|
return steps;
|
|
16026
16026
|
}
|
|
16027
|
-
function getTreePositions(size) {
|
|
16027
|
+
function getTreePositions$1(size) {
|
|
16028
16028
|
const positions = [];
|
|
16029
16029
|
const width = 280;
|
|
16030
16030
|
for (let i = 0; i < size; i++) {
|
|
@@ -16048,7 +16048,7 @@ const PriorityQueueVisualizerComponent = ({ showControls = true, showCode = true
|
|
|
16048
16048
|
const playingRef = React.useRef(false);
|
|
16049
16049
|
const timeoutRef = React.useRef(null);
|
|
16050
16050
|
const initialize = React.useCallback(() => {
|
|
16051
|
-
const newSteps = generateHeapSteps();
|
|
16051
|
+
const newSteps = generateHeapSteps$1();
|
|
16052
16052
|
setSteps(newSteps);
|
|
16053
16053
|
setCurrentStep(0);
|
|
16054
16054
|
setIsPlaying(false);
|
|
@@ -16136,7 +16136,7 @@ const PriorityQueueVisualizerComponent = ({ showControls = true, showCode = true
|
|
|
16136
16136
|
description: ""
|
|
16137
16137
|
};
|
|
16138
16138
|
const { heap, highlightIndex, swapIndices, compareIndices, description, siftPath, currentIndex } = currentStepData;
|
|
16139
|
-
const positions = getTreePositions(heap.length);
|
|
16139
|
+
const positions = getTreePositions$1(heap.length);
|
|
16140
16140
|
const getNodeStyle = (idx) => {
|
|
16141
16141
|
if (idx === highlightIndex) {
|
|
16142
16142
|
return "fill-purple-500 stroke-purple-600";
|
|
@@ -16312,7 +16312,7 @@ const PriorityQueueVisualizerComponent = ({ showControls = true, showCode = true
|
|
|
16312
16312
|
{
|
|
16313
16313
|
id: "priorityqueue-visualizer",
|
|
16314
16314
|
title: "PriorityQueue (Min-Heap)",
|
|
16315
|
-
badges: BADGES$
|
|
16315
|
+
badges: BADGES$f,
|
|
16316
16316
|
gradient: "purple",
|
|
16317
16317
|
className,
|
|
16318
16318
|
minHeight: 400,
|
|
@@ -16335,8 +16335,8 @@ const PriorityQueueVisualizerComponent = ({ showControls = true, showCode = true
|
|
|
16335
16335
|
accentColor: "purple"
|
|
16336
16336
|
},
|
|
16337
16337
|
showControls,
|
|
16338
|
-
legendItems: LEGEND_ITEMS$
|
|
16339
|
-
code: showCode ? HEAP_CODE : void 0,
|
|
16338
|
+
legendItems: LEGEND_ITEMS$f,
|
|
16339
|
+
code: showCode ? HEAP_CODE$1 : void 0,
|
|
16340
16340
|
currentCodeLine: currentStepData == null ? void 0 : currentStepData.codeLine,
|
|
16341
16341
|
codeVariables: currentStepData == null ? void 0 : currentStepData.variables,
|
|
16342
16342
|
showCode,
|
|
@@ -16347,6 +16347,454 @@ const PriorityQueueVisualizerComponent = ({ showControls = true, showCode = true
|
|
|
16347
16347
|
const PriorityQueueVisualizer = React.memo(
|
|
16348
16348
|
PriorityQueueVisualizerComponent
|
|
16349
16349
|
);
|
|
16350
|
+
const VISUALIZER_ID = "heap-visualizer";
|
|
16351
|
+
const INITIAL_ARRAY$1 = [4, 10, 3, 5, 1, 8, 7, 2, 9, 6];
|
|
16352
|
+
const BADGES$e = [
|
|
16353
|
+
{ label: "Build: O(n)", variant: "orange" },
|
|
16354
|
+
{ label: "Sort: O(n log n)", variant: "amber" }
|
|
16355
|
+
];
|
|
16356
|
+
const HEAP_CODE = [
|
|
16357
|
+
"function buildMaxHeap(arr):",
|
|
16358
|
+
" n = arr.length",
|
|
16359
|
+
" # Start from last non-leaf node",
|
|
16360
|
+
" for i = n/2 - 1 down to 0:",
|
|
16361
|
+
" heapify(arr, n, i)",
|
|
16362
|
+
"",
|
|
16363
|
+
"function heapify(arr, n, i):",
|
|
16364
|
+
" largest = i",
|
|
16365
|
+
" left = 2*i + 1",
|
|
16366
|
+
" right = 2*i + 2",
|
|
16367
|
+
" if left < n and arr[left] > arr[largest]:",
|
|
16368
|
+
" largest = left",
|
|
16369
|
+
" if right < n and arr[right] > arr[largest]:",
|
|
16370
|
+
" largest = right",
|
|
16371
|
+
" if largest != i:",
|
|
16372
|
+
" swap(arr[i], arr[largest])",
|
|
16373
|
+
" heapify(arr, n, largest)",
|
|
16374
|
+
"",
|
|
16375
|
+
"function heapSort(arr):",
|
|
16376
|
+
" buildMaxHeap(arr)",
|
|
16377
|
+
" for i = n-1 down to 1:",
|
|
16378
|
+
" swap(arr[0], arr[i]) # Move max to end",
|
|
16379
|
+
" heapify(arr, i, 0) # Restore heap"
|
|
16380
|
+
];
|
|
16381
|
+
const LEGEND_ITEMS$e = [
|
|
16382
|
+
{ color: "bg-orange-500", label: "Root (max)" },
|
|
16383
|
+
{ color: "bg-amber-400", label: "Comparing" },
|
|
16384
|
+
{ color: "bg-green-400", label: "Swapped" },
|
|
16385
|
+
{ color: "bg-blue-200", label: "Current node", border: "#60a5fa" },
|
|
16386
|
+
{ color: "bg-gray-300", label: "Sorted portion" }
|
|
16387
|
+
];
|
|
16388
|
+
function generateHeapSteps(initialArray) {
|
|
16389
|
+
const steps = [];
|
|
16390
|
+
const arr = [...initialArray];
|
|
16391
|
+
const n = arr.length;
|
|
16392
|
+
steps.push({
|
|
16393
|
+
operation: "init",
|
|
16394
|
+
array: [...arr],
|
|
16395
|
+
heapSize: n,
|
|
16396
|
+
description: `Initial array: [${arr.join(", ")}]. Will build max-heap then sort.`,
|
|
16397
|
+
codeLine: -1,
|
|
16398
|
+
phase: "build"
|
|
16399
|
+
});
|
|
16400
|
+
steps.push({
|
|
16401
|
+
operation: "buildHeap",
|
|
16402
|
+
array: [...arr],
|
|
16403
|
+
heapSize: n,
|
|
16404
|
+
description: `Build Max-Heap: Start from last non-leaf node (index ${Math.floor(n / 2) - 1})`,
|
|
16405
|
+
codeLine: 3,
|
|
16406
|
+
variables: { n, "start": Math.floor(n / 2) - 1 },
|
|
16407
|
+
phase: "build"
|
|
16408
|
+
});
|
|
16409
|
+
for (let i = Math.floor(n / 2) - 1; i >= 0; i--) {
|
|
16410
|
+
heapifyWithSteps(arr, n, i, steps, "build");
|
|
16411
|
+
}
|
|
16412
|
+
steps.push({
|
|
16413
|
+
operation: "buildHeap",
|
|
16414
|
+
array: [...arr],
|
|
16415
|
+
heapSize: n,
|
|
16416
|
+
description: `✓ Max-Heap built! Root (${arr[0]}) is the maximum element.`,
|
|
16417
|
+
codeLine: 4,
|
|
16418
|
+
phase: "build"
|
|
16419
|
+
});
|
|
16420
|
+
steps.push({
|
|
16421
|
+
operation: "heapSort",
|
|
16422
|
+
array: [...arr],
|
|
16423
|
+
heapSize: n,
|
|
16424
|
+
description: "HeapSort: Extract max elements one by one",
|
|
16425
|
+
codeLine: 18,
|
|
16426
|
+
phase: "sort"
|
|
16427
|
+
});
|
|
16428
|
+
const sorted = [];
|
|
16429
|
+
for (let i = n - 1; i > 0; i--) {
|
|
16430
|
+
steps.push({
|
|
16431
|
+
operation: "extract",
|
|
16432
|
+
array: [...arr],
|
|
16433
|
+
heapSize: i + 1,
|
|
16434
|
+
sortedPortion: [...sorted],
|
|
16435
|
+
highlightIndex: 0,
|
|
16436
|
+
description: `Extract max: Move ${arr[0]} (root) to position ${i}`,
|
|
16437
|
+
codeLine: 21,
|
|
16438
|
+
variables: { max: arr[0], position: i },
|
|
16439
|
+
phase: "sort"
|
|
16440
|
+
});
|
|
16441
|
+
[arr[0], arr[i]] = [arr[i], arr[0]];
|
|
16442
|
+
sorted.unshift(i);
|
|
16443
|
+
steps.push({
|
|
16444
|
+
operation: "extract",
|
|
16445
|
+
array: [...arr],
|
|
16446
|
+
heapSize: i,
|
|
16447
|
+
sortedPortion: [...sorted],
|
|
16448
|
+
swapIndices: [0, i],
|
|
16449
|
+
description: `Swapped! ${arr[i]} is now in final sorted position. Heap size reduced to ${i}.`,
|
|
16450
|
+
codeLine: 21,
|
|
16451
|
+
variables: { "sorted": arr[i] },
|
|
16452
|
+
phase: "sort"
|
|
16453
|
+
});
|
|
16454
|
+
if (i > 1) {
|
|
16455
|
+
heapifyWithSteps(arr, i, 0, steps, "sort", sorted);
|
|
16456
|
+
}
|
|
16457
|
+
}
|
|
16458
|
+
sorted.unshift(0);
|
|
16459
|
+
steps.push({
|
|
16460
|
+
operation: "done",
|
|
16461
|
+
array: [...arr],
|
|
16462
|
+
heapSize: 0,
|
|
16463
|
+
sortedPortion: Array.from({ length: n }, (_, i) => i),
|
|
16464
|
+
description: `✓ HeapSort complete! Array sorted: [${arr.join(", ")}]`,
|
|
16465
|
+
codeLine: -1,
|
|
16466
|
+
phase: "sort"
|
|
16467
|
+
});
|
|
16468
|
+
return steps;
|
|
16469
|
+
}
|
|
16470
|
+
function heapifyWithSteps(arr, heapSize, i, steps, phase, sortedPortion = []) {
|
|
16471
|
+
const left = 2 * i + 1;
|
|
16472
|
+
const right = 2 * i + 2;
|
|
16473
|
+
let largest = i;
|
|
16474
|
+
steps.push({
|
|
16475
|
+
operation: "heapify",
|
|
16476
|
+
array: [...arr],
|
|
16477
|
+
heapSize,
|
|
16478
|
+
sortedPortion: [...sortedPortion],
|
|
16479
|
+
highlightIndex: i,
|
|
16480
|
+
description: `heapify(${i}): Check node ${arr[i]} against children`,
|
|
16481
|
+
codeLine: 6,
|
|
16482
|
+
variables: { i, "arr[i]": arr[i], left, right },
|
|
16483
|
+
phase
|
|
16484
|
+
});
|
|
16485
|
+
if (left < heapSize) {
|
|
16486
|
+
steps.push({
|
|
16487
|
+
operation: "compare",
|
|
16488
|
+
array: [...arr],
|
|
16489
|
+
heapSize,
|
|
16490
|
+
sortedPortion: [...sortedPortion],
|
|
16491
|
+
compareIndices: [i, left],
|
|
16492
|
+
description: `Compare: ${arr[left]} (left) ${arr[left] > arr[largest] ? ">" : "≤"} ${arr[largest]} (current largest)`,
|
|
16493
|
+
codeLine: 10,
|
|
16494
|
+
variables: { left, "arr[left]": arr[left], largest, "arr[largest]": arr[largest] },
|
|
16495
|
+
phase
|
|
16496
|
+
});
|
|
16497
|
+
if (arr[left] > arr[largest]) {
|
|
16498
|
+
largest = left;
|
|
16499
|
+
}
|
|
16500
|
+
}
|
|
16501
|
+
if (right < heapSize) {
|
|
16502
|
+
steps.push({
|
|
16503
|
+
operation: "compare",
|
|
16504
|
+
array: [...arr],
|
|
16505
|
+
heapSize,
|
|
16506
|
+
sortedPortion: [...sortedPortion],
|
|
16507
|
+
compareIndices: [largest, right],
|
|
16508
|
+
description: `Compare: ${arr[right]} (right) ${arr[right] > arr[largest] ? ">" : "≤"} ${arr[largest]} (current largest)`,
|
|
16509
|
+
codeLine: 12,
|
|
16510
|
+
variables: { right, "arr[right]": arr[right], largest, "arr[largest]": arr[largest] },
|
|
16511
|
+
phase
|
|
16512
|
+
});
|
|
16513
|
+
if (arr[right] > arr[largest]) {
|
|
16514
|
+
largest = right;
|
|
16515
|
+
}
|
|
16516
|
+
}
|
|
16517
|
+
if (largest !== i) {
|
|
16518
|
+
steps.push({
|
|
16519
|
+
operation: "swap",
|
|
16520
|
+
array: [...arr],
|
|
16521
|
+
heapSize,
|
|
16522
|
+
sortedPortion: [...sortedPortion],
|
|
16523
|
+
swapIndices: [i, largest],
|
|
16524
|
+
description: `Swap: ${arr[i]} ↔ ${arr[largest]} (largest child)`,
|
|
16525
|
+
codeLine: 15,
|
|
16526
|
+
variables: { i, largest, "arr[i]": arr[i], "arr[largest]": arr[largest] },
|
|
16527
|
+
phase
|
|
16528
|
+
});
|
|
16529
|
+
[arr[i], arr[largest]] = [arr[largest], arr[i]];
|
|
16530
|
+
steps.push({
|
|
16531
|
+
operation: "swap",
|
|
16532
|
+
array: [...arr],
|
|
16533
|
+
heapSize,
|
|
16534
|
+
sortedPortion: [...sortedPortion],
|
|
16535
|
+
highlightIndex: largest,
|
|
16536
|
+
description: `Swapped! Continue heapify from index ${largest}`,
|
|
16537
|
+
codeLine: 16,
|
|
16538
|
+
variables: { "next": largest },
|
|
16539
|
+
phase
|
|
16540
|
+
});
|
|
16541
|
+
heapifyWithSteps(arr, heapSize, largest, steps, phase, sortedPortion);
|
|
16542
|
+
} else {
|
|
16543
|
+
steps.push({
|
|
16544
|
+
operation: "heapify",
|
|
16545
|
+
array: [...arr],
|
|
16546
|
+
heapSize,
|
|
16547
|
+
sortedPortion: [...sortedPortion],
|
|
16548
|
+
highlightIndex: i,
|
|
16549
|
+
description: `Node ${arr[i]} satisfies heap property (≥ both children)`,
|
|
16550
|
+
codeLine: 14,
|
|
16551
|
+
phase
|
|
16552
|
+
});
|
|
16553
|
+
}
|
|
16554
|
+
}
|
|
16555
|
+
function getTreePositions(size) {
|
|
16556
|
+
const positions = [];
|
|
16557
|
+
const width = 320;
|
|
16558
|
+
for (let i = 0; i < size; i++) {
|
|
16559
|
+
const level = Math.floor(Math.log2(i + 1));
|
|
16560
|
+
const levelStart = Math.pow(2, level) - 1;
|
|
16561
|
+
const posInLevel = i - levelStart;
|
|
16562
|
+
const nodesInLevel = Math.pow(2, level);
|
|
16563
|
+
const spacing = width / (nodesInLevel + 1);
|
|
16564
|
+
positions.push({
|
|
16565
|
+
x: spacing * (posInLevel + 1),
|
|
16566
|
+
y: level * 55 + 30
|
|
16567
|
+
});
|
|
16568
|
+
}
|
|
16569
|
+
return positions;
|
|
16570
|
+
}
|
|
16571
|
+
const HeapVisualizerComponent = ({
|
|
16572
|
+
showControls = true,
|
|
16573
|
+
showCode = true,
|
|
16574
|
+
className = ""
|
|
16575
|
+
}) => {
|
|
16576
|
+
const { copyUrlToClipboard } = useUrlState({ prefix: "heap", scrollToId: VISUALIZER_ID });
|
|
16577
|
+
const generateSteps = React.useMemo(() => () => generateHeapSteps(INITIAL_ARRAY$1), []);
|
|
16578
|
+
const {
|
|
16579
|
+
steps,
|
|
16580
|
+
currentStep,
|
|
16581
|
+
currentStepData,
|
|
16582
|
+
isPlaying,
|
|
16583
|
+
speed,
|
|
16584
|
+
setSpeed,
|
|
16585
|
+
handlePlayPause,
|
|
16586
|
+
handleStep,
|
|
16587
|
+
handleStepBack,
|
|
16588
|
+
handleReset
|
|
16589
|
+
} = useVisualizerPlayback({
|
|
16590
|
+
generateSteps
|
|
16591
|
+
});
|
|
16592
|
+
const stepData = currentStepData || {
|
|
16593
|
+
operation: "init",
|
|
16594
|
+
array: INITIAL_ARRAY$1,
|
|
16595
|
+
heapSize: INITIAL_ARRAY$1.length,
|
|
16596
|
+
description: ""
|
|
16597
|
+
};
|
|
16598
|
+
const { array, heapSize, sortedPortion, highlightIndex, compareIndices, swapIndices, description, phase } = stepData;
|
|
16599
|
+
const positions = getTreePositions(array.length);
|
|
16600
|
+
const getNodeStyle = (idx) => {
|
|
16601
|
+
if (sortedPortion == null ? void 0 : sortedPortion.includes(idx)) {
|
|
16602
|
+
return "fill-gray-300 stroke-gray-400";
|
|
16603
|
+
}
|
|
16604
|
+
if (swapIndices == null ? void 0 : swapIndices.includes(idx)) {
|
|
16605
|
+
return "fill-green-400 stroke-green-500";
|
|
16606
|
+
}
|
|
16607
|
+
if (compareIndices == null ? void 0 : compareIndices.includes(idx)) {
|
|
16608
|
+
return "fill-amber-400 stroke-amber-500";
|
|
16609
|
+
}
|
|
16610
|
+
if (idx === highlightIndex) {
|
|
16611
|
+
return "fill-blue-200 stroke-blue-400";
|
|
16612
|
+
}
|
|
16613
|
+
if (idx === 0 && idx < heapSize) {
|
|
16614
|
+
return "fill-orange-500 stroke-orange-600";
|
|
16615
|
+
}
|
|
16616
|
+
if (idx < heapSize) {
|
|
16617
|
+
return "fill-white stroke-gray-300";
|
|
16618
|
+
}
|
|
16619
|
+
return "fill-gray-200 stroke-gray-300";
|
|
16620
|
+
};
|
|
16621
|
+
const getTextColor = (idx) => {
|
|
16622
|
+
if (sortedPortion == null ? void 0 : sortedPortion.includes(idx)) return "#374151";
|
|
16623
|
+
if ((swapIndices == null ? void 0 : swapIndices.includes(idx)) || idx === 0 && idx < heapSize) return "white";
|
|
16624
|
+
return "#374151";
|
|
16625
|
+
};
|
|
16626
|
+
const getStatusVariant = () => {
|
|
16627
|
+
if (stepData.operation === "done") return "success";
|
|
16628
|
+
if (stepData.operation === "swap") return "warning";
|
|
16629
|
+
return "default";
|
|
16630
|
+
};
|
|
16631
|
+
const handleShare = React.useCallback(async () => {
|
|
16632
|
+
return copyUrlToClipboard({ step: currentStep });
|
|
16633
|
+
}, [copyUrlToClipboard, currentStep]);
|
|
16634
|
+
const visualization = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
16635
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-4 p-4 bg-gradient-to-r from-orange-50 to-amber-50 rounded-xl border-2 border-orange-200", children: [
|
|
16636
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-sm font-bold text-orange-800 mb-2 flex items-center gap-2", children: [
|
|
16637
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-lg", children: "🔺" }),
|
|
16638
|
+
" Max-Heap Property"
|
|
16639
|
+
] }),
|
|
16640
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "font-mono text-sm bg-white rounded-lg p-3 border border-orange-200", children: [
|
|
16641
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-center text-orange-700 font-bold mb-2", children: "heap[parent] ≥ heap[children]" }),
|
|
16642
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 sm:grid-cols-3 gap-2 text-xs text-gray-600", children: [
|
|
16643
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-orange-50 p-2 rounded text-center", children: [
|
|
16644
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-semibold", children: "parent(i)" }),
|
|
16645
|
+
" = ⌊(i-1)/2⌋"
|
|
16646
|
+
] }),
|
|
16647
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-orange-50 p-2 rounded text-center", children: [
|
|
16648
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-semibold", children: "left(i)" }),
|
|
16649
|
+
" = 2i + 1"
|
|
16650
|
+
] }),
|
|
16651
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-orange-50 p-2 rounded text-center", children: [
|
|
16652
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-semibold", children: "right(i)" }),
|
|
16653
|
+
" = 2i + 2"
|
|
16654
|
+
] })
|
|
16655
|
+
] })
|
|
16656
|
+
] }),
|
|
16657
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-3 p-2 bg-white rounded-lg border border-orange-200 min-h-[36px] flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: `px-3 py-1 rounded-full text-xs font-medium ${phase === "build" ? "bg-orange-100 text-orange-700" : phase === "sort" ? "bg-amber-100 text-amber-700" : "bg-gray-100 text-gray-500"}`, children: phase === "build" ? "🔨 Building Max-Heap" : phase === "sort" ? "📊 HeapSort in progress" : "Ready" }) })
|
|
16658
|
+
] }),
|
|
16659
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-4", children: [
|
|
16660
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-sm font-medium text-gray-700 mb-2 flex items-center justify-between", children: [
|
|
16661
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
16662
|
+
"Binary Max-Heap (size: ",
|
|
16663
|
+
heapSize,
|
|
16664
|
+
")"
|
|
16665
|
+
] }),
|
|
16666
|
+
sortedPortion && sortedPortion.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs text-gray-500", children: [
|
|
16667
|
+
"Sorted: ",
|
|
16668
|
+
sortedPortion.length,
|
|
16669
|
+
" elements"
|
|
16670
|
+
] })
|
|
16671
|
+
] }),
|
|
16672
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-gray-50 rounded-lg p-2 overflow-x-auto", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
16673
|
+
"svg",
|
|
16674
|
+
{
|
|
16675
|
+
width: "320",
|
|
16676
|
+
height: Math.max(Math.floor(Math.log2(array.length)) * 55 + 80, 120),
|
|
16677
|
+
className: "mx-auto",
|
|
16678
|
+
children: [
|
|
16679
|
+
array.map((_, idx) => {
|
|
16680
|
+
if (idx === 0) return null;
|
|
16681
|
+
const parentIdx = Math.floor((idx - 1) / 2);
|
|
16682
|
+
const parentPos = positions[parentIdx];
|
|
16683
|
+
const childPos = positions[idx];
|
|
16684
|
+
if (!parentPos || !childPos) return null;
|
|
16685
|
+
const isSorted = (sortedPortion == null ? void 0 : sortedPortion.includes(idx)) || (sortedPortion == null ? void 0 : sortedPortion.includes(parentIdx));
|
|
16686
|
+
const isActive = (compareIndices == null ? void 0 : compareIndices.includes(idx)) && (compareIndices == null ? void 0 : compareIndices.includes(parentIdx)) || (swapIndices == null ? void 0 : swapIndices.includes(idx)) && (swapIndices == null ? void 0 : swapIndices.includes(parentIdx));
|
|
16687
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
16688
|
+
"line",
|
|
16689
|
+
{
|
|
16690
|
+
x1: parentPos.x,
|
|
16691
|
+
y1: parentPos.y,
|
|
16692
|
+
x2: childPos.x,
|
|
16693
|
+
y2: childPos.y,
|
|
16694
|
+
stroke: isSorted ? "#d1d5db" : isActive ? "#f59e0b" : "#d1d5db",
|
|
16695
|
+
strokeWidth: isActive ? 3 : 1,
|
|
16696
|
+
strokeDasharray: idx >= heapSize ? "4,2" : void 0
|
|
16697
|
+
},
|
|
16698
|
+
`edge-${idx}`
|
|
16699
|
+
);
|
|
16700
|
+
}),
|
|
16701
|
+
array.map((val, idx) => {
|
|
16702
|
+
const pos = positions[idx];
|
|
16703
|
+
if (!pos) return null;
|
|
16704
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("g", { transform: `translate(${pos.x}, ${pos.y})`, children: [
|
|
16705
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
16706
|
+
"circle",
|
|
16707
|
+
{
|
|
16708
|
+
r: "18",
|
|
16709
|
+
className: `${getNodeStyle(idx)} stroke-2 transition-colors`
|
|
16710
|
+
}
|
|
16711
|
+
),
|
|
16712
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
16713
|
+
"text",
|
|
16714
|
+
{
|
|
16715
|
+
textAnchor: "middle",
|
|
16716
|
+
dy: "5",
|
|
16717
|
+
className: "text-xs font-bold",
|
|
16718
|
+
fill: getTextColor(idx),
|
|
16719
|
+
children: val
|
|
16720
|
+
}
|
|
16721
|
+
),
|
|
16722
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
16723
|
+
"text",
|
|
16724
|
+
{
|
|
16725
|
+
textAnchor: "middle",
|
|
16726
|
+
dy: "32",
|
|
16727
|
+
className: "text-[9px]",
|
|
16728
|
+
fill: "#9ca3af",
|
|
16729
|
+
children: [
|
|
16730
|
+
"[",
|
|
16731
|
+
idx,
|
|
16732
|
+
"]"
|
|
16733
|
+
]
|
|
16734
|
+
}
|
|
16735
|
+
)
|
|
16736
|
+
] }, idx);
|
|
16737
|
+
})
|
|
16738
|
+
]
|
|
16739
|
+
}
|
|
16740
|
+
) })
|
|
16741
|
+
] }),
|
|
16742
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-4 p-3 bg-gray-100 rounded-lg", children: [
|
|
16743
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-xs text-gray-600 mb-2 font-medium", children: [
|
|
16744
|
+
"Array representation (heap size: ",
|
|
16745
|
+
heapSize,
|
|
16746
|
+
")"
|
|
16747
|
+
] }),
|
|
16748
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex gap-1 overflow-x-auto", children: array.map((val, idx) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
16749
|
+
"div",
|
|
16750
|
+
{
|
|
16751
|
+
className: `w-8 h-8 flex items-center justify-center rounded text-xs font-mono transition-colors ${(sortedPortion == null ? void 0 : sortedPortion.includes(idx)) ? "bg-gray-300 text-gray-600" : (swapIndices == null ? void 0 : swapIndices.includes(idx)) ? "bg-green-400 text-white" : (compareIndices == null ? void 0 : compareIndices.includes(idx)) ? "bg-amber-400 text-white" : idx === highlightIndex ? "bg-blue-200 text-blue-700 ring-2 ring-blue-400" : idx === 0 && idx < heapSize ? "bg-orange-500 text-white" : idx < heapSize ? "bg-white border border-gray-300 text-gray-700" : "bg-gray-200 text-gray-400"}`,
|
|
16752
|
+
children: val
|
|
16753
|
+
},
|
|
16754
|
+
idx
|
|
16755
|
+
)) }),
|
|
16756
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex gap-1 mt-1", children: array.map((_, idx) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-8 text-center text-[9px] text-gray-400", children: idx }, idx)) })
|
|
16757
|
+
] })
|
|
16758
|
+
] });
|
|
16759
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
16760
|
+
BaseVisualizerLayout,
|
|
16761
|
+
{
|
|
16762
|
+
id: VISUALIZER_ID,
|
|
16763
|
+
title: "Heap (Max-Heap & HeapSort)",
|
|
16764
|
+
badges: BADGES$e,
|
|
16765
|
+
gradient: "orange",
|
|
16766
|
+
className,
|
|
16767
|
+
minHeight: 450,
|
|
16768
|
+
onShare: handleShare,
|
|
16769
|
+
status: {
|
|
16770
|
+
description,
|
|
16771
|
+
currentStep,
|
|
16772
|
+
totalSteps: steps.length,
|
|
16773
|
+
variant: getStatusVariant()
|
|
16774
|
+
},
|
|
16775
|
+
controls: {
|
|
16776
|
+
isPlaying,
|
|
16777
|
+
currentStep,
|
|
16778
|
+
totalSteps: steps.length,
|
|
16779
|
+
speed,
|
|
16780
|
+
onPlayPause: handlePlayPause,
|
|
16781
|
+
onStep: handleStep,
|
|
16782
|
+
onStepBack: handleStepBack,
|
|
16783
|
+
onReset: handleReset,
|
|
16784
|
+
onSpeedChange: setSpeed,
|
|
16785
|
+
accentColor: "orange"
|
|
16786
|
+
},
|
|
16787
|
+
showControls,
|
|
16788
|
+
legendItems: LEGEND_ITEMS$e,
|
|
16789
|
+
code: showCode ? HEAP_CODE : void 0,
|
|
16790
|
+
currentCodeLine: currentStepData == null ? void 0 : currentStepData.codeLine,
|
|
16791
|
+
codeVariables: currentStepData == null ? void 0 : currentStepData.variables,
|
|
16792
|
+
showCode,
|
|
16793
|
+
children: visualization
|
|
16794
|
+
}
|
|
16795
|
+
);
|
|
16796
|
+
};
|
|
16797
|
+
const HeapVisualizer = React.memo(HeapVisualizerComponent);
|
|
16350
16798
|
const SEGMENT_COUNT = 4;
|
|
16351
16799
|
const OPERATIONS$7 = [
|
|
16352
16800
|
{ thread: "T1", op: "put", key: "Alice", value: 100 },
|
|
@@ -22374,6 +22822,7 @@ exports.GraphVisualizer = GraphVisualizer;
|
|
|
22374
22822
|
exports.HashMapInterviewVisualizer = HashMapInterviewVisualizer;
|
|
22375
22823
|
exports.HashMapVisualizer = HashMapVisualizer;
|
|
22376
22824
|
exports.HashTableVisualizer = HashTableVisualizer;
|
|
22825
|
+
exports.HeapVisualizer = HeapVisualizer;
|
|
22377
22826
|
exports.HelpPanel = HelpPanel;
|
|
22378
22827
|
exports.ImmutableCollectionsVisualizer = ImmutableCollectionsVisualizer;
|
|
22379
22828
|
exports.InterviewModePanel = InterviewModePanel;
|