@tomaszjarosz/react-visualizers 0.4.13 → 0.4.14
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/README.md +5 -3
- package/dist/index.cjs +603 -205
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.js +603 -205
- package/dist/index.js.map +1 -1
- package/dist/react-visualizers.css +4 -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$M = [
|
|
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$K = [
|
|
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$K,
|
|
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$M,
|
|
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$L = [
|
|
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$L,
|
|
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$J = [
|
|
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$K = [
|
|
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$J,
|
|
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$K,
|
|
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$I = [
|
|
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$J = [
|
|
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$I,
|
|
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$J,
|
|
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$I = [
|
|
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$I,
|
|
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$H = [
|
|
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$G = [
|
|
|
5076
5076
|
{ color: "bg-yellow-400", label: "Current" },
|
|
5077
5077
|
{ color: "bg-purple-400", label: "Path" }
|
|
5078
5078
|
];
|
|
5079
|
-
const BADGES$
|
|
5079
|
+
const BADGES$H = [
|
|
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$H,
|
|
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$H,
|
|
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$G = [
|
|
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$G = [
|
|
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$G,
|
|
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$G,
|
|
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,
|
|
@@ -5795,7 +5795,7 @@ const TopologicalSortVisualizerComponent = ({
|
|
|
5795
5795
|
};
|
|
5796
5796
|
const TopologicalSortVisualizer = React.memo(TopologicalSortVisualizerComponent);
|
|
5797
5797
|
const BUCKET_COUNT$2 = 8;
|
|
5798
|
-
const OPERATIONS$
|
|
5798
|
+
const OPERATIONS$o = [
|
|
5799
5799
|
{ op: "put", key: "Alice", value: 25 },
|
|
5800
5800
|
{ op: "put", key: "Bob", value: 30 },
|
|
5801
5801
|
{ op: "put", key: "Charlie", value: 35 },
|
|
@@ -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$F = [
|
|
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$F = [
|
|
5837
5837
|
{ label: "Avg: O(1)", variant: "indigo" },
|
|
5838
5838
|
{ label: "Worst: O(n)", variant: "purple" }
|
|
5839
5839
|
];
|
|
@@ -5856,7 +5856,7 @@ function generateHashMapSteps$1() {
|
|
|
5856
5856
|
description: `Initialize HashMap with ${BUCKET_COUNT$2} buckets. Each bucket is a linked list for collision handling.`,
|
|
5857
5857
|
codeLine: -1
|
|
5858
5858
|
});
|
|
5859
|
-
for (const { op, key, value } of OPERATIONS$
|
|
5859
|
+
for (const { op, key, value } of OPERATIONS$o) {
|
|
5860
5860
|
const hash = simpleHash$7(key);
|
|
5861
5861
|
const index = hash % BUCKET_COUNT$2;
|
|
5862
5862
|
if (op === "put") {
|
|
@@ -6094,7 +6094,7 @@ const HashMapVisualizerComponent = ({
|
|
|
6094
6094
|
{
|
|
6095
6095
|
id: VISUALIZER_ID2,
|
|
6096
6096
|
title: "HashMap Operations",
|
|
6097
|
-
badges: BADGES$
|
|
6097
|
+
badges: BADGES$F,
|
|
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$F,
|
|
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,
|
|
@@ -6129,7 +6129,7 @@ const HashMapVisualizerComponent = ({
|
|
|
6129
6129
|
};
|
|
6130
6130
|
const HashMapVisualizer = React.memo(HashMapVisualizerComponent);
|
|
6131
6131
|
const CAPACITY$1 = 3;
|
|
6132
|
-
const OPERATIONS$
|
|
6132
|
+
const OPERATIONS$n = [
|
|
6133
6133
|
{ op: "put", key: 1, value: "A" },
|
|
6134
6134
|
{ op: "put", key: 2, value: "B" },
|
|
6135
6135
|
{ op: "put", key: 3, value: "C" },
|
|
@@ -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$E = [
|
|
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$D = [
|
|
|
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$E = [
|
|
6179
6179
|
{ label: "O(1) get/put", variant: "orange" },
|
|
6180
6180
|
{ label: "HashMap + DLL", variant: "orange" }
|
|
6181
6181
|
];
|
|
@@ -6253,7 +6253,7 @@ function generateLRUSteps() {
|
|
|
6253
6253
|
nodes.delete(evictedKey);
|
|
6254
6254
|
return evictedKey;
|
|
6255
6255
|
};
|
|
6256
|
-
for (const operation of OPERATIONS$
|
|
6256
|
+
for (const operation of OPERATIONS$n) {
|
|
6257
6257
|
if (operation.op === "get") {
|
|
6258
6258
|
const key = operation.key;
|
|
6259
6259
|
steps.push({
|
|
@@ -6528,7 +6528,7 @@ const LRUCacheVisualizerComponent = ({
|
|
|
6528
6528
|
{
|
|
6529
6529
|
id: VISUALIZER_ID2,
|
|
6530
6530
|
title: "LRU Cache",
|
|
6531
|
-
badges: BADGES$
|
|
6531
|
+
badges: BADGES$E,
|
|
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$E,
|
|
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,14 +6562,14 @@ const LRUCacheVisualizerComponent = ({
|
|
|
6562
6562
|
);
|
|
6563
6563
|
};
|
|
6564
6564
|
const LRUCacheVisualizer = React.memo(LRUCacheVisualizerComponent);
|
|
6565
|
-
const VISUALIZER_ID$
|
|
6565
|
+
const VISUALIZER_ID$b = "hashmap-interview-visualizer";
|
|
6566
6566
|
const BUCKET_COUNT$1 = 8;
|
|
6567
|
-
const BADGES$
|
|
6567
|
+
const BADGES$D = [
|
|
6568
6568
|
{ label: "Interview Mode", variant: "purple" },
|
|
6569
6569
|
{ label: "O(1) avg", variant: "green" },
|
|
6570
6570
|
{ label: "Hash Table", variant: "indigo" }
|
|
6571
6571
|
];
|
|
6572
|
-
const OPERATIONS$
|
|
6572
|
+
const OPERATIONS$m = [
|
|
6573
6573
|
{ op: "put", key: "Alice", value: 25 },
|
|
6574
6574
|
{ op: "put", key: "Bob", value: 30 },
|
|
6575
6575
|
{ op: "put", key: "Charlie", value: 35 },
|
|
@@ -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$D = [
|
|
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" },
|
|
@@ -6707,7 +6707,7 @@ function generateHashMapSteps() {
|
|
|
6707
6707
|
buckets: buckets.map((b) => ({ entries: [...b.entries] })),
|
|
6708
6708
|
description: `Initialize HashMap with ${BUCKET_COUNT$1} buckets`
|
|
6709
6709
|
});
|
|
6710
|
-
for (const { op, key, value } of OPERATIONS$
|
|
6710
|
+
for (const { op, key, value } of OPERATIONS$m) {
|
|
6711
6711
|
const hash = simpleHash$6(key);
|
|
6712
6712
|
const index = hash % BUCKET_COUNT$1;
|
|
6713
6713
|
if (op === "put") {
|
|
@@ -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$b });
|
|
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$b,
|
|
6908
6908
|
title: "HashMap (Interview Mode)",
|
|
6909
|
-
badges: BADGES$
|
|
6909
|
+
badges: BADGES$D,
|
|
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$D,
|
|
6934
6934
|
sidePanel,
|
|
6935
6935
|
children: visualization
|
|
6936
6936
|
}
|
|
@@ -6938,7 +6938,7 @@ const HashMapInterviewVisualizerComponent = ({
|
|
|
6938
6938
|
};
|
|
6939
6939
|
const HashMapInterviewVisualizer = React.memo(HashMapInterviewVisualizerComponent);
|
|
6940
6940
|
const INITIAL_DATA = [10, 20, 30, 40, 50];
|
|
6941
|
-
const OPERATIONS$
|
|
6941
|
+
const OPERATIONS$l = [
|
|
6942
6942
|
{ op: "get", index: 2 },
|
|
6943
6943
|
{ op: "addLast", value: 60 },
|
|
6944
6944
|
{ op: "addFirst", value: 5 },
|
|
@@ -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$C = [
|
|
6951
6951
|
{ label: "Comparison", variant: "blue" }
|
|
6952
6952
|
];
|
|
6953
|
-
const LEGEND_ITEMS$
|
|
6953
|
+
const LEGEND_ITEMS$C = [
|
|
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" },
|
|
@@ -6976,7 +6976,7 @@ function generateListComparisonSteps() {
|
|
|
6976
6976
|
description: `Initialize both lists with [${INITIAL_DATA.join(", ")}]`,
|
|
6977
6977
|
phase: "complete"
|
|
6978
6978
|
});
|
|
6979
|
-
for (const { op, index, value } of OPERATIONS$
|
|
6979
|
+
for (const { op, index, value } of OPERATIONS$l) {
|
|
6980
6980
|
switch (op) {
|
|
6981
6981
|
case "get": {
|
|
6982
6982
|
const idx = index;
|
|
@@ -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$C,
|
|
7449
7449
|
gradient: "blue",
|
|
7450
7450
|
className,
|
|
7451
7451
|
minHeight: 400,
|
|
@@ -7469,19 +7469,19 @@ const ListComparisonVisualizerComponent = ({
|
|
|
7469
7469
|
accentColor: "blue"
|
|
7470
7470
|
},
|
|
7471
7471
|
showControls,
|
|
7472
|
-
legendItems: LEGEND_ITEMS$
|
|
7472
|
+
legendItems: LEGEND_ITEMS$C,
|
|
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$a = "treeset-interview-visualizer";
|
|
7479
|
+
const BADGES$B = [
|
|
7480
7480
|
{ label: "Interview Mode", variant: "purple" },
|
|
7481
7481
|
{ label: "BST", variant: "green" },
|
|
7482
7482
|
{ label: "O(log n)", variant: "teal" }
|
|
7483
7483
|
];
|
|
7484
|
-
const OPERATIONS$
|
|
7484
|
+
const OPERATIONS$k = [
|
|
7485
7485
|
{ op: "add", value: 50 },
|
|
7486
7486
|
{ op: "add", value: 30 },
|
|
7487
7487
|
{ op: "add", value: 70 },
|
|
@@ -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$B = [
|
|
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" }
|
|
@@ -7656,7 +7656,7 @@ function generateTreeSetSteps$1() {
|
|
|
7656
7656
|
path: [],
|
|
7657
7657
|
description: "Initialize empty TreeSet (Binary Search Tree)"
|
|
7658
7658
|
});
|
|
7659
|
-
for (const { op, value } of OPERATIONS$
|
|
7659
|
+
for (const { op, value } of OPERATIONS$k) {
|
|
7660
7660
|
if (op === "add") {
|
|
7661
7661
|
const path = tree ? findPath$1(tree, value) : [];
|
|
7662
7662
|
if (tree) {
|
|
@@ -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$a });
|
|
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$a,
|
|
7865
7865
|
title: "TreeSet / BST (Interview Mode)",
|
|
7866
|
-
badges: BADGES$
|
|
7866
|
+
badges: BADGES$B,
|
|
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$B,
|
|
7891
7891
|
sidePanel,
|
|
7892
7892
|
children: visualization
|
|
7893
7893
|
}
|
|
7894
7894
|
);
|
|
7895
7895
|
};
|
|
7896
7896
|
const TreeSetInterviewVisualizer = React.memo(TreeSetInterviewVisualizerComponent);
|
|
7897
|
-
const VISUALIZER_ID$
|
|
7897
|
+
const VISUALIZER_ID$9 = "sorting-interview-visualizer";
|
|
7898
7898
|
const INITIAL_ARRAY$2 = [64, 34, 25, 12, 22, 11, 90];
|
|
7899
|
-
const BADGES$
|
|
7899
|
+
const BADGES$A = [
|
|
7900
7900
|
{ label: "O(n log n) avg", variant: "amber" }
|
|
7901
7901
|
];
|
|
7902
|
-
const LEGEND_ITEMS$
|
|
7902
|
+
const LEGEND_ITEMS$A = [
|
|
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,7 +8095,7 @@ 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$9 });
|
|
8099
8099
|
const [mode, setMode] = React.useState("visualize");
|
|
8100
8100
|
const generateSteps = React.useMemo(() => () => generateQuickSortSteps(INITIAL_ARRAY$2), []);
|
|
8101
8101
|
const playback = useVisualizerPlayback({ generateSteps });
|
|
@@ -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$9,
|
|
8188
8188
|
title: "QuickSort (Interview Mode)",
|
|
8189
|
-
badges: BADGES$
|
|
8189
|
+
badges: BADGES$A,
|
|
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$A,
|
|
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$8 = "graph-interview-visualizer";
|
|
8222
|
+
const BADGES$z = [
|
|
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$z = [
|
|
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$8 });
|
|
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$8,
|
|
8624
8624
|
title: "Graph Traversal (Interview Mode)",
|
|
8625
|
-
badges: BADGES$
|
|
8625
|
+
badges: BADGES$z,
|
|
8626
8626
|
gradient: "blue",
|
|
8627
8627
|
className,
|
|
8628
8628
|
minHeight: 500,
|
|
@@ -8646,22 +8646,22 @@ const GraphInterviewVisualizerComponent = ({
|
|
|
8646
8646
|
accentColor: "blue"
|
|
8647
8647
|
},
|
|
8648
8648
|
showControls,
|
|
8649
|
-
legendItems: LEGEND_ITEMS$
|
|
8649
|
+
legendItems: LEGEND_ITEMS$z,
|
|
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$7 = "bloomfilter-interview-visualizer";
|
|
8657
8657
|
const BIT_ARRAY_SIZE$1 = 16;
|
|
8658
8658
|
const K_HASH_FUNCTIONS = 3;
|
|
8659
|
-
const BADGES$
|
|
8659
|
+
const BADGES$y = [
|
|
8660
8660
|
{ label: "Interview Mode", variant: "purple" },
|
|
8661
8661
|
{ label: "Probabilistic", variant: "pink" },
|
|
8662
8662
|
{ label: "No False Negatives", variant: "indigo" }
|
|
8663
8663
|
];
|
|
8664
|
-
const OPERATIONS$
|
|
8664
|
+
const OPERATIONS$j = [
|
|
8665
8665
|
{ op: "add", element: "apple" },
|
|
8666
8666
|
{ op: "add", element: "banana" },
|
|
8667
8667
|
{ op: "add", element: "cherry" },
|
|
@@ -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$y = [
|
|
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" }
|
|
@@ -8827,7 +8827,7 @@ function generateBloomFilterSteps$1() {
|
|
|
8827
8827
|
bitArray: [...bitArray],
|
|
8828
8828
|
description: `Initialize Bloom Filter: ${BIT_ARRAY_SIZE$1} bits, ${K_HASH_FUNCTIONS} hash functions`
|
|
8829
8829
|
});
|
|
8830
|
-
for (const { op, element } of OPERATIONS$
|
|
8830
|
+
for (const { op, element } of OPERATIONS$j) {
|
|
8831
8831
|
const positions = getHashPositions(element);
|
|
8832
8832
|
if (op === "add") {
|
|
8833
8833
|
steps.push({
|
|
@@ -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$7 });
|
|
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$7,
|
|
8999
8999
|
title: "Bloom Filter (Interview Mode)",
|
|
9000
|
-
badges: BADGES$
|
|
9000
|
+
badges: BADGES$y,
|
|
9001
9001
|
gradient: "purple",
|
|
9002
9002
|
className,
|
|
9003
9003
|
minHeight: 500,
|
|
@@ -9022,21 +9022,21 @@ const BloomFilterInterviewVisualizerComponent = ({
|
|
|
9022
9022
|
accentColor: "purple"
|
|
9023
9023
|
},
|
|
9024
9024
|
showControls,
|
|
9025
|
-
legendItems: LEGEND_ITEMS$
|
|
9025
|
+
legendItems: LEGEND_ITEMS$y,
|
|
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$6 = "btree-interview-visualizer";
|
|
9033
9033
|
const ORDER$1 = 3;
|
|
9034
|
-
const BADGES$
|
|
9034
|
+
const BADGES$x = [
|
|
9035
9035
|
{ label: "Interview Mode", variant: "purple" },
|
|
9036
9036
|
{ label: `Order ${ORDER$1}`, variant: "green" },
|
|
9037
9037
|
{ label: "O(log n)", variant: "teal" }
|
|
9038
9038
|
];
|
|
9039
|
-
const OPERATIONS$
|
|
9039
|
+
const OPERATIONS$i = [
|
|
9040
9040
|
{ op: "insert", value: 10 },
|
|
9041
9041
|
{ op: "insert", value: 20 },
|
|
9042
9042
|
{ op: "insert", value: 5 },
|
|
@@ -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$x = [
|
|
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" }
|
|
@@ -9237,7 +9237,7 @@ function generateBTreeSteps$1() {
|
|
|
9237
9237
|
}
|
|
9238
9238
|
return { node };
|
|
9239
9239
|
}
|
|
9240
|
-
for (const { op, value } of OPERATIONS$
|
|
9240
|
+
for (const { op, value } of OPERATIONS$i) {
|
|
9241
9241
|
if (op === "insert") {
|
|
9242
9242
|
steps.push({
|
|
9243
9243
|
operation: "insert",
|
|
@@ -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$6 });
|
|
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$6,
|
|
9452
9452
|
title: "B-Tree (Interview Mode)",
|
|
9453
|
-
badges: BADGES$
|
|
9453
|
+
badges: BADGES$x,
|
|
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$x,
|
|
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$w = [
|
|
9486
9486
|
{ label: "O((V+E) log V)", variant: "orange" }
|
|
9487
9487
|
];
|
|
9488
|
-
const LEGEND_ITEMS$
|
|
9488
|
+
const LEGEND_ITEMS$w = [
|
|
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$w,
|
|
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$w,
|
|
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$v = [
|
|
9880
9880
|
{ label: "O(n×W)", variant: "cyan" }
|
|
9881
9881
|
];
|
|
9882
|
-
const LEGEND_ITEMS$
|
|
9882
|
+
const LEGEND_ITEMS$v = [
|
|
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$v,
|
|
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$v,
|
|
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$u = [
|
|
10272
10272
|
{ label: "Distributed Systems", variant: "cyan" }
|
|
10273
10273
|
];
|
|
10274
|
-
const LEGEND_ITEMS$
|
|
10274
|
+
const LEGEND_ITEMS$u = [
|
|
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$u,
|
|
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$u,
|
|
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$t = [
|
|
10720
10720
|
{ label: "Distributed Consensus", variant: "orange" }
|
|
10721
10721
|
];
|
|
10722
|
-
const LEGEND_ITEMS$
|
|
10722
|
+
const LEGEND_ITEMS$t = [
|
|
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$t,
|
|
11153
11153
|
gradient: "orange",
|
|
11154
11154
|
className,
|
|
11155
11155
|
minHeight: 400,
|
|
@@ -11174,18 +11174,18 @@ const RaftInterviewVisualizerComponent = ({
|
|
|
11174
11174
|
accentColor: "orange"
|
|
11175
11175
|
},
|
|
11176
11176
|
showControls,
|
|
11177
|
-
legendItems: LEGEND_ITEMS$
|
|
11177
|
+
legendItems: LEGEND_ITEMS$t,
|
|
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$5 = "trie-interview-visualizer";
|
|
11185
|
+
const BADGES$s = [
|
|
11186
11186
|
{ label: "O(m) ops", variant: "cyan" }
|
|
11187
11187
|
];
|
|
11188
|
-
const OPERATIONS$
|
|
11188
|
+
const OPERATIONS$h = [
|
|
11189
11189
|
{ op: "insert", word: "cat" },
|
|
11190
11190
|
{ op: "insert", word: "car" },
|
|
11191
11191
|
{ op: "insert", word: "card" },
|
|
@@ -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$s = [
|
|
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" },
|
|
@@ -11361,7 +11361,7 @@ function generateTrieSteps$1() {
|
|
|
11361
11361
|
rootId,
|
|
11362
11362
|
description: "Initialize empty Trie with root node"
|
|
11363
11363
|
});
|
|
11364
|
-
for (const { op, word } of OPERATIONS$
|
|
11364
|
+
for (const { op, word } of OPERATIONS$h) {
|
|
11365
11365
|
if (op === "insert") {
|
|
11366
11366
|
let currentId = rootId;
|
|
11367
11367
|
const path = [rootId];
|
|
@@ -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$5 });
|
|
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$5,
|
|
11612
11612
|
title: "Trie (Prefix Tree) - Interview Mode",
|
|
11613
|
-
badges: BADGES$
|
|
11613
|
+
badges: BADGES$s,
|
|
11614
11614
|
gradient: "cyan",
|
|
11615
11615
|
className,
|
|
11616
11616
|
minHeight: 500,
|
|
@@ -11635,19 +11635,19 @@ const TrieInterviewVisualizerComponent = ({
|
|
|
11635
11635
|
accentColor: "cyan"
|
|
11636
11636
|
},
|
|
11637
11637
|
showControls,
|
|
11638
|
-
legendItems: LEGEND_ITEMS$
|
|
11638
|
+
legendItems: LEGEND_ITEMS$s,
|
|
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$4 = "unionfind-interview-visualizer";
|
|
11646
11646
|
const INITIAL_SIZE$2 = 8;
|
|
11647
|
-
const BADGES$
|
|
11647
|
+
const BADGES$r = [
|
|
11648
11648
|
{ label: "O(α(n))", variant: "purple" }
|
|
11649
11649
|
];
|
|
11650
|
-
const OPERATIONS$
|
|
11650
|
+
const OPERATIONS$g = [
|
|
11651
11651
|
{ op: "union", a: 0, b: 1 },
|
|
11652
11652
|
{ op: "union", a: 2, b: 3 },
|
|
11653
11653
|
{ op: "union", a: 4, b: 5 },
|
|
@@ -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$r = [
|
|
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" }
|
|
@@ -11810,7 +11810,7 @@ function generateUnionFindSteps$1() {
|
|
|
11810
11810
|
}
|
|
11811
11811
|
return { root: current, path };
|
|
11812
11812
|
};
|
|
11813
|
-
for (const operation of OPERATIONS$
|
|
11813
|
+
for (const operation of OPERATIONS$g) {
|
|
11814
11814
|
if (operation.op === "find") {
|
|
11815
11815
|
const x = operation.a;
|
|
11816
11816
|
const { root, path } = find(x, true);
|
|
@@ -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$4 });
|
|
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$4,
|
|
12013
12013
|
title: "Union-Find (DSU) - Interview Mode",
|
|
12014
|
-
badges: BADGES$
|
|
12014
|
+
badges: BADGES$r,
|
|
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$r,
|
|
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$3 = "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$q = [
|
|
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$q = [
|
|
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$3 });
|
|
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$3,
|
|
12421
12421
|
title: "A* Pathfinding (Interview Mode)",
|
|
12422
|
-
badges: BADGES$
|
|
12422
|
+
badges: BADGES$q,
|
|
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$q,
|
|
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$p = [
|
|
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$p = [
|
|
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$p,
|
|
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$p,
|
|
12777
12777
|
sidePanel,
|
|
12778
12778
|
children: visualization
|
|
12779
12779
|
}
|
|
12780
12780
|
);
|
|
12781
12781
|
};
|
|
12782
12782
|
const SkipListInterviewVisualizer = React.memo(SkipListInterviewVisualizerComponent);
|
|
12783
|
-
const VISUALIZER_ID$
|
|
12784
|
-
const BADGES$
|
|
12783
|
+
const VISUALIZER_ID$2 = "linkedlist-interview-visualizer";
|
|
12784
|
+
const BADGES$o = [
|
|
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$o = [
|
|
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$2 });
|
|
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$2,
|
|
13050
13050
|
title: "Linked List (Interview Mode)",
|
|
13051
|
-
badges: BADGES$
|
|
13051
|
+
badges: BADGES$o,
|
|
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$o,
|
|
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$n = [
|
|
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$n = [
|
|
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$n,
|
|
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$n,
|
|
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,
|
|
@@ -13455,7 +13455,7 @@ const HashTableVisualizerComponent = ({
|
|
|
13455
13455
|
);
|
|
13456
13456
|
};
|
|
13457
13457
|
const HashTableVisualizer = React.memo(HashTableVisualizerComponent);
|
|
13458
|
-
const OPERATIONS$
|
|
13458
|
+
const OPERATIONS$f = [
|
|
13459
13459
|
{ op: "addFirst", value: 10 },
|
|
13460
13460
|
{ op: "addLast", value: 20 },
|
|
13461
13461
|
{ op: "addLast", value: 30 },
|
|
@@ -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$m = [
|
|
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$m = [
|
|
13495
13495
|
{ label: "Ends: O(1)", variant: "blue" },
|
|
13496
13496
|
{ label: "Index: O(n)", variant: "indigo" }
|
|
13497
13497
|
];
|
|
@@ -13507,7 +13507,7 @@ function generateLinkedListSteps() {
|
|
|
13507
13507
|
description: "Initialize empty LinkedList (doubly-linked). O(1) for add/remove at ends, O(n) for indexed access.",
|
|
13508
13508
|
codeLine: -1
|
|
13509
13509
|
});
|
|
13510
|
-
for (const { op, value, index } of OPERATIONS$
|
|
13510
|
+
for (const { op, value, index } of OPERATIONS$f) {
|
|
13511
13511
|
if (op === "addFirst" && value !== void 0) {
|
|
13512
13512
|
const newNode = { value, id: nodeIdCounter$2++ };
|
|
13513
13513
|
nodes = [newNode, ...nodes];
|
|
@@ -13689,7 +13689,7 @@ const LinkedListVisualizerComponent = ({
|
|
|
13689
13689
|
{
|
|
13690
13690
|
id: VISUALIZER_ID2,
|
|
13691
13691
|
title: "LinkedList Operations",
|
|
13692
|
-
badges: BADGES$
|
|
13692
|
+
badges: BADGES$m,
|
|
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$m,
|
|
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,
|
|
@@ -13724,7 +13724,7 @@ const LinkedListVisualizerComponent = ({
|
|
|
13724
13724
|
};
|
|
13725
13725
|
const LinkedListVisualizer = React.memo(LinkedListVisualizerComponent);
|
|
13726
13726
|
const BUCKET_COUNT = 6;
|
|
13727
|
-
const OPERATIONS$
|
|
13727
|
+
const OPERATIONS$e = [
|
|
13728
13728
|
{ op: "put", key: "A", value: 10 },
|
|
13729
13729
|
{ op: "put", key: "B", value: 20 },
|
|
13730
13730
|
{ op: "put", key: "C", value: 30 },
|
|
@@ -13760,13 +13760,13 @@ const LINKEDHASHMAP_CODE = [
|
|
|
13760
13760
|
" }",
|
|
13761
13761
|
"}"
|
|
13762
13762
|
];
|
|
13763
|
-
const LEGEND_ITEMS$
|
|
13763
|
+
const LEGEND_ITEMS$l = [
|
|
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$l = [
|
|
13770
13770
|
{ label: "O(1) ops", variant: "orange" },
|
|
13771
13771
|
{ label: "Ordered", variant: "amber" }
|
|
13772
13772
|
];
|
|
@@ -13793,7 +13793,7 @@ function generateLinkedHashMapSteps(accessOrder = true) {
|
|
|
13793
13793
|
codeLine: 0,
|
|
13794
13794
|
accessOrder
|
|
13795
13795
|
});
|
|
13796
|
-
for (const { op, key, value } of OPERATIONS$
|
|
13796
|
+
for (const { op, key, value } of OPERATIONS$e) {
|
|
13797
13797
|
const hash = simpleHash$2(key);
|
|
13798
13798
|
const index = hash % BUCKET_COUNT;
|
|
13799
13799
|
if (op === "put") {
|
|
@@ -14178,7 +14178,7 @@ const LinkedHashMapVisualizerComponent = ({
|
|
|
14178
14178
|
{
|
|
14179
14179
|
id: VISUALIZER_ID2,
|
|
14180
14180
|
title: "LinkedHashMap",
|
|
14181
|
-
badges: BADGES$
|
|
14181
|
+
badges: BADGES$l,
|
|
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$l,
|
|
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,
|
|
@@ -14214,7 +14214,7 @@ const LinkedHashMapVisualizerComponent = ({
|
|
|
14214
14214
|
};
|
|
14215
14215
|
const LinkedHashMapVisualizer = React.memo(LinkedHashMapVisualizerComponent);
|
|
14216
14216
|
const INITIAL_CAPACITY$1 = 4;
|
|
14217
|
-
const OPERATIONS$
|
|
14217
|
+
const OPERATIONS$d = [
|
|
14218
14218
|
{ op: "add", value: 10 },
|
|
14219
14219
|
{ op: "add", value: 20 },
|
|
14220
14220
|
{ op: "add", value: 30 },
|
|
@@ -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$k = [
|
|
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$k = [
|
|
14254
14254
|
{ label: "Get: O(1)", variant: "orange" },
|
|
14255
14255
|
{ label: "Add: O(1)*", variant: "amber" }
|
|
14256
14256
|
];
|
|
@@ -14267,7 +14267,7 @@ function generateArrayListSteps() {
|
|
|
14267
14267
|
description: `Initialize ArrayList with capacity ${capacity}. Auto-grows when full (amortized O(1) add).`,
|
|
14268
14268
|
codeLine: -1
|
|
14269
14269
|
});
|
|
14270
|
-
for (const { op, value, index } of OPERATIONS$
|
|
14270
|
+
for (const { op, value, index } of OPERATIONS$d) {
|
|
14271
14271
|
if (op === "add" && value !== void 0) {
|
|
14272
14272
|
if (size === capacity) {
|
|
14273
14273
|
const oldCapacity = capacity;
|
|
@@ -14538,7 +14538,7 @@ const ArrayListVisualizerComponent = ({
|
|
|
14538
14538
|
{
|
|
14539
14539
|
id: VISUALIZER_ID2,
|
|
14540
14540
|
title: "ArrayList Operations",
|
|
14541
|
-
badges: BADGES$
|
|
14541
|
+
badges: BADGES$k,
|
|
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$k,
|
|
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,
|
|
@@ -14573,7 +14573,7 @@ const ArrayListVisualizerComponent = ({
|
|
|
14573
14573
|
};
|
|
14574
14574
|
const ArrayListVisualizer = React.memo(ArrayListVisualizerComponent);
|
|
14575
14575
|
const INITIAL_CAPACITY = 8;
|
|
14576
|
-
const OPERATIONS$
|
|
14576
|
+
const OPERATIONS$c = [
|
|
14577
14577
|
{ op: "addLast", value: 10 },
|
|
14578
14578
|
{ op: "addLast", value: 20 },
|
|
14579
14579
|
{ op: "addFirst", value: 5 },
|
|
@@ -14619,14 +14619,14 @@ const ARRAYDEQUE_CODE = [
|
|
|
14619
14619
|
" }",
|
|
14620
14620
|
"}"
|
|
14621
14621
|
];
|
|
14622
|
-
const LEGEND_ITEMS$
|
|
14622
|
+
const LEGEND_ITEMS$j = [
|
|
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$j = [
|
|
14630
14630
|
{ label: "O(1) all ops", variant: "teal" },
|
|
14631
14631
|
{ label: "Circular buffer", variant: "purple" }
|
|
14632
14632
|
];
|
|
@@ -14647,7 +14647,7 @@ function generateArrayDequeSteps() {
|
|
|
14647
14647
|
codeLine: 0,
|
|
14648
14648
|
variables: { head, tail, capacity, size: 0 }
|
|
14649
14649
|
});
|
|
14650
|
-
for (const { op, value } of OPERATIONS$
|
|
14650
|
+
for (const { op, value } of OPERATIONS$c) {
|
|
14651
14651
|
if (op === "addFirst" && value !== void 0) {
|
|
14652
14652
|
if (getSize() === capacity - 1) {
|
|
14653
14653
|
const oldCapacity = capacity;
|
|
@@ -14978,7 +14978,7 @@ const ArrayDequeVisualizerComponent = ({
|
|
|
14978
14978
|
{
|
|
14979
14979
|
id: VISUALIZER_ID2,
|
|
14980
14980
|
title: "ArrayDeque",
|
|
14981
|
-
badges: BADGES$
|
|
14981
|
+
badges: BADGES$j,
|
|
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$j,
|
|
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,
|
|
@@ -15013,7 +15013,7 @@ const ArrayDequeVisualizerComponent = ({
|
|
|
15013
15013
|
);
|
|
15014
15014
|
};
|
|
15015
15015
|
const ArrayDequeVisualizer = React.memo(ArrayDequeVisualizerComponent);
|
|
15016
|
-
const OPERATIONS$
|
|
15016
|
+
const OPERATIONS$b = [
|
|
15017
15017
|
{ op: "add", value: 50 },
|
|
15018
15018
|
{ op: "add", value: 30 },
|
|
15019
15019
|
{ op: "add", value: 70 },
|
|
@@ -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$i = [
|
|
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$i = [
|
|
15054
15054
|
{ label: "Avg: O(log n)", variant: "green" },
|
|
15055
15055
|
{ label: "Worst: O(n)", variant: "amber" }
|
|
15056
15056
|
];
|
|
@@ -15097,7 +15097,7 @@ function generateTreeSetSteps() {
|
|
|
15097
15097
|
description: "Initialize empty TreeSet (Binary Search Tree). Values are stored in sorted order.",
|
|
15098
15098
|
codeLine: -1
|
|
15099
15099
|
});
|
|
15100
|
-
for (const { op, value } of OPERATIONS$
|
|
15100
|
+
for (const { op, value } of OPERATIONS$b) {
|
|
15101
15101
|
if (op === "add") {
|
|
15102
15102
|
const path = tree ? findPath(tree, value) : [];
|
|
15103
15103
|
if (tree) {
|
|
@@ -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$i,
|
|
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$i,
|
|
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,
|
|
@@ -15459,7 +15459,7 @@ const DAYS_OF_WEEK = [
|
|
|
15459
15459
|
"SATURDAY",
|
|
15460
15460
|
"SUNDAY"
|
|
15461
15461
|
];
|
|
15462
|
-
const OPERATIONS$
|
|
15462
|
+
const OPERATIONS$a = [
|
|
15463
15463
|
{ op: "add", value: "MONDAY" },
|
|
15464
15464
|
{ op: "add", value: "WEDNESDAY" },
|
|
15465
15465
|
{ op: "add", value: "FRIDAY" },
|
|
@@ -15492,13 +15492,13 @@ const ENUMSET_CODE = [
|
|
|
15492
15492
|
" }",
|
|
15493
15493
|
"}"
|
|
15494
15494
|
];
|
|
15495
|
-
const LEGEND_ITEMS$
|
|
15495
|
+
const LEGEND_ITEMS$h = [
|
|
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$h = [
|
|
15502
15502
|
{ label: "O(1) all ops", variant: "green" },
|
|
15503
15503
|
{ label: "Memory efficient", variant: "green" }
|
|
15504
15504
|
];
|
|
@@ -15515,7 +15515,7 @@ function generateEnumSetSteps() {
|
|
|
15515
15515
|
codeLine: 1,
|
|
15516
15516
|
variables: { elements: "0b0000000" }
|
|
15517
15517
|
});
|
|
15518
|
-
for (const { op, value } of OPERATIONS$
|
|
15518
|
+
for (const { op, value } of OPERATIONS$a) {
|
|
15519
15519
|
const bitPos = getBitPosition(value);
|
|
15520
15520
|
const bitMaskForValue = 1 << bitPos;
|
|
15521
15521
|
const previousBitmask = bitmask;
|
|
@@ -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$h,
|
|
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$h,
|
|
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,
|
|
@@ -15802,7 +15802,7 @@ const EnumSetVisualizerComponent = ({
|
|
|
15802
15802
|
);
|
|
15803
15803
|
};
|
|
15804
15804
|
const EnumSetVisualizer = React.memo(EnumSetVisualizerComponent);
|
|
15805
|
-
const OPERATIONS$
|
|
15805
|
+
const OPERATIONS$9 = [
|
|
15806
15806
|
{ op: "offer", value: 50 },
|
|
15807
15807
|
{ op: "offer", value: 30 },
|
|
15808
15808
|
{ op: "offer", value: 70 },
|
|
@@ -15831,18 +15831,18 @@ const HEAP_CODE$1 = [
|
|
|
15831
15831
|
" siftDown(0)",
|
|
15832
15832
|
" return result"
|
|
15833
15833
|
];
|
|
15834
|
-
const LEGEND_ITEMS$
|
|
15834
|
+
const LEGEND_ITEMS$g = [
|
|
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$g = [
|
|
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$2() {
|
|
15846
15846
|
const steps = [];
|
|
15847
15847
|
const heap = [];
|
|
15848
15848
|
steps.push({
|
|
@@ -15851,7 +15851,7 @@ function generateHeapSteps$1() {
|
|
|
15851
15851
|
description: "Initialize min-heap PriorityQueue. Parent is always smaller than children. O(log n) insert/remove.",
|
|
15852
15852
|
codeLine: -1
|
|
15853
15853
|
});
|
|
15854
|
-
for (const { op, value } of OPERATIONS$
|
|
15854
|
+
for (const { op, value } of OPERATIONS$9) {
|
|
15855
15855
|
if (op === "offer" && value !== void 0) {
|
|
15856
15856
|
heap.push(value);
|
|
15857
15857
|
let idx = heap.length - 1;
|
|
@@ -16024,7 +16024,7 @@ function generateHeapSteps$1() {
|
|
|
16024
16024
|
});
|
|
16025
16025
|
return steps;
|
|
16026
16026
|
}
|
|
16027
|
-
function getTreePositions$
|
|
16027
|
+
function getTreePositions$2(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$2();
|
|
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$
|
|
16139
|
+
const positions = getTreePositions$2(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$g,
|
|
16316
16316
|
gradient: "purple",
|
|
16317
16317
|
className,
|
|
16318
16318
|
minHeight: 400,
|
|
@@ -16335,7 +16335,7 @@ const PriorityQueueVisualizerComponent = ({ showControls = true, showCode = true
|
|
|
16335
16335
|
accentColor: "purple"
|
|
16336
16336
|
},
|
|
16337
16337
|
showControls,
|
|
16338
|
-
legendItems: LEGEND_ITEMS$
|
|
16338
|
+
legendItems: LEGEND_ITEMS$g,
|
|
16339
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,
|
|
@@ -16347,9 +16347,9 @@ const PriorityQueueVisualizerComponent = ({ showControls = true, showCode = true
|
|
|
16347
16347
|
const PriorityQueueVisualizer = React.memo(
|
|
16348
16348
|
PriorityQueueVisualizerComponent
|
|
16349
16349
|
);
|
|
16350
|
-
const VISUALIZER_ID = "heap-visualizer";
|
|
16350
|
+
const VISUALIZER_ID$1 = "heap-visualizer";
|
|
16351
16351
|
const INITIAL_ARRAY$1 = [4, 10, 3, 5, 1, 8, 7, 2, 9, 6];
|
|
16352
|
-
const BADGES$
|
|
16352
|
+
const BADGES$f = [
|
|
16353
16353
|
{ label: "Build: O(n)", variant: "orange" },
|
|
16354
16354
|
{ label: "Sort: O(n log n)", variant: "amber" }
|
|
16355
16355
|
];
|
|
@@ -16378,14 +16378,14 @@ const HEAP_CODE = [
|
|
|
16378
16378
|
" swap(arr[0], arr[i]) # Move max to end",
|
|
16379
16379
|
" heapify(arr, i, 0) # Restore heap"
|
|
16380
16380
|
];
|
|
16381
|
-
const LEGEND_ITEMS$
|
|
16381
|
+
const LEGEND_ITEMS$f = [
|
|
16382
16382
|
{ color: "bg-orange-500", label: "Root (max)" },
|
|
16383
16383
|
{ color: "bg-amber-400", label: "Comparing" },
|
|
16384
16384
|
{ color: "bg-green-400", label: "Swapped" },
|
|
16385
16385
|
{ color: "bg-blue-200", label: "Current node", border: "#60a5fa" },
|
|
16386
16386
|
{ color: "bg-gray-300", label: "Sorted portion" }
|
|
16387
16387
|
];
|
|
16388
|
-
function generateHeapSteps(initialArray) {
|
|
16388
|
+
function generateHeapSteps$1(initialArray) {
|
|
16389
16389
|
const steps = [];
|
|
16390
16390
|
const arr = [...initialArray];
|
|
16391
16391
|
const n = arr.length;
|
|
@@ -16552,7 +16552,7 @@ function heapifyWithSteps(arr, heapSize, i, steps, phase, sortedPortion = []) {
|
|
|
16552
16552
|
});
|
|
16553
16553
|
}
|
|
16554
16554
|
}
|
|
16555
|
-
function getTreePositions(size) {
|
|
16555
|
+
function getTreePositions$1(size) {
|
|
16556
16556
|
const positions = [];
|
|
16557
16557
|
const width = 320;
|
|
16558
16558
|
for (let i = 0; i < size; i++) {
|
|
@@ -16573,8 +16573,8 @@ const HeapVisualizerComponent = ({
|
|
|
16573
16573
|
showCode = true,
|
|
16574
16574
|
className = ""
|
|
16575
16575
|
}) => {
|
|
16576
|
-
const { copyUrlToClipboard } = useUrlState({ prefix: "heap", scrollToId: VISUALIZER_ID });
|
|
16577
|
-
const generateSteps = React.useMemo(() => () => generateHeapSteps(INITIAL_ARRAY$1), []);
|
|
16576
|
+
const { copyUrlToClipboard } = useUrlState({ prefix: "heap", scrollToId: VISUALIZER_ID$1 });
|
|
16577
|
+
const generateSteps = React.useMemo(() => () => generateHeapSteps$1(INITIAL_ARRAY$1), []);
|
|
16578
16578
|
const {
|
|
16579
16579
|
steps,
|
|
16580
16580
|
currentStep,
|
|
@@ -16596,7 +16596,7 @@ const HeapVisualizerComponent = ({
|
|
|
16596
16596
|
description: ""
|
|
16597
16597
|
};
|
|
16598
16598
|
const { array, heapSize, sortedPortion, highlightIndex, compareIndices, swapIndices, description, phase } = stepData;
|
|
16599
|
-
const positions = getTreePositions(array.length);
|
|
16599
|
+
const positions = getTreePositions$1(array.length);
|
|
16600
16600
|
const getNodeStyle = (idx) => {
|
|
16601
16601
|
if (sortedPortion == null ? void 0 : sortedPortion.includes(idx)) {
|
|
16602
16602
|
return "fill-gray-300 stroke-gray-400";
|
|
@@ -16759,9 +16759,9 @@ const HeapVisualizerComponent = ({
|
|
|
16759
16759
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
16760
16760
|
BaseVisualizerLayout,
|
|
16761
16761
|
{
|
|
16762
|
-
id: VISUALIZER_ID,
|
|
16762
|
+
id: VISUALIZER_ID$1,
|
|
16763
16763
|
title: "Heap (Max-Heap & HeapSort)",
|
|
16764
|
-
badges: BADGES$
|
|
16764
|
+
badges: BADGES$f,
|
|
16765
16765
|
gradient: "orange",
|
|
16766
16766
|
className,
|
|
16767
16767
|
minHeight: 450,
|
|
@@ -16785,7 +16785,7 @@ const HeapVisualizerComponent = ({
|
|
|
16785
16785
|
accentColor: "orange"
|
|
16786
16786
|
},
|
|
16787
16787
|
showControls,
|
|
16788
|
-
legendItems: LEGEND_ITEMS$
|
|
16788
|
+
legendItems: LEGEND_ITEMS$f,
|
|
16789
16789
|
code: showCode ? HEAP_CODE : void 0,
|
|
16790
16790
|
currentCodeLine: currentStepData == null ? void 0 : currentStepData.codeLine,
|
|
16791
16791
|
codeVariables: currentStepData == null ? void 0 : currentStepData.variables,
|
|
@@ -16795,6 +16795,403 @@ const HeapVisualizerComponent = ({
|
|
|
16795
16795
|
);
|
|
16796
16796
|
};
|
|
16797
16797
|
const HeapVisualizer = React.memo(HeapVisualizerComponent);
|
|
16798
|
+
const VISUALIZER_ID = "heap-interview-visualizer";
|
|
16799
|
+
const BADGES$e = [
|
|
16800
|
+
{ label: "Interview Mode", variant: "orange" },
|
|
16801
|
+
{ label: "Max-Heap", variant: "amber" }
|
|
16802
|
+
];
|
|
16803
|
+
const OPERATIONS$8 = [
|
|
16804
|
+
{ op: "insert", value: 40 },
|
|
16805
|
+
{ op: "insert", value: 20 },
|
|
16806
|
+
{ op: "insert", value: 60 },
|
|
16807
|
+
{ op: "insert", value: 10 },
|
|
16808
|
+
{ op: "insert", value: 50 },
|
|
16809
|
+
{ op: "extractMax" },
|
|
16810
|
+
{ op: "insert", value: 55 },
|
|
16811
|
+
{ op: "extractMax" }
|
|
16812
|
+
];
|
|
16813
|
+
const LEGEND_ITEMS$e = [
|
|
16814
|
+
{ color: "bg-orange-500", label: "Root (max)" },
|
|
16815
|
+
{ color: "bg-amber-400", label: "Comparing" },
|
|
16816
|
+
{ color: "bg-green-400", label: "Swapped" },
|
|
16817
|
+
{ color: "bg-blue-200", label: "Current", border: "#60a5fa" }
|
|
16818
|
+
];
|
|
16819
|
+
const HEAP_QUESTIONS = [
|
|
16820
|
+
{
|
|
16821
|
+
id: "heap-1",
|
|
16822
|
+
question: "What is the time complexity of inserting an element into a heap?",
|
|
16823
|
+
options: ["O(1)", "O(log n)", "O(n)", "O(n log n)"],
|
|
16824
|
+
correctAnswer: 1,
|
|
16825
|
+
explanation: 'Insertion is O(log n) because after adding the element at the end, we may need to "sift up" through at most log n levels (height of the tree) to restore the heap property.',
|
|
16826
|
+
hint: "Think about the height of a complete binary tree.",
|
|
16827
|
+
difficulty: "easy",
|
|
16828
|
+
topic: "Time Complexity"
|
|
16829
|
+
},
|
|
16830
|
+
{
|
|
16831
|
+
id: "heap-2",
|
|
16832
|
+
question: "What is the time complexity of building a heap from an unsorted array?",
|
|
16833
|
+
options: ["O(n)", "O(n log n)", "O(n²)", "O(log n)"],
|
|
16834
|
+
correctAnswer: 0,
|
|
16835
|
+
explanation: "Building a heap using bottom-up heapify is O(n), not O(n log n)! This is because most nodes are near the bottom and require few swaps. The mathematical analysis shows the total work is O(n).",
|
|
16836
|
+
hint: "It's better than calling insert() n times.",
|
|
16837
|
+
difficulty: "medium",
|
|
16838
|
+
topic: "Build Heap"
|
|
16839
|
+
},
|
|
16840
|
+
{
|
|
16841
|
+
id: "heap-3",
|
|
16842
|
+
question: "In a max-heap stored as an array, what is the index of the left child of node at index i?",
|
|
16843
|
+
options: ["i + 1", "2i", "2i + 1", "(i - 1) / 2"],
|
|
16844
|
+
correctAnswer: 2,
|
|
16845
|
+
explanation: "For 0-indexed arrays: left child = 2i + 1, right child = 2i + 2, parent = ⌊(i-1)/2⌋. For 1-indexed: left = 2i, right = 2i + 1, parent = ⌊i/2⌋.",
|
|
16846
|
+
hint: "The formula depends on whether the array is 0-indexed or 1-indexed.",
|
|
16847
|
+
difficulty: "easy",
|
|
16848
|
+
topic: "Index Formulas"
|
|
16849
|
+
},
|
|
16850
|
+
{
|
|
16851
|
+
id: "heap-4",
|
|
16852
|
+
question: "What type of binary tree is a heap?",
|
|
16853
|
+
options: ["Full binary tree", "Complete binary tree", "Perfect binary tree", "Binary search tree"],
|
|
16854
|
+
correctAnswer: 1,
|
|
16855
|
+
explanation: "A heap is a complete binary tree: all levels are fully filled except possibly the last, which is filled from left to right. This allows efficient array storage without pointers.",
|
|
16856
|
+
difficulty: "easy",
|
|
16857
|
+
topic: "Structure"
|
|
16858
|
+
},
|
|
16859
|
+
{
|
|
16860
|
+
id: "heap-5",
|
|
16861
|
+
question: "What is the time complexity of HeapSort?",
|
|
16862
|
+
options: ["O(n)", "O(n log n)", "O(n²)", "O(log n)"],
|
|
16863
|
+
correctAnswer: 1,
|
|
16864
|
+
explanation: "HeapSort is O(n log n): O(n) to build the heap, then n extract operations each taking O(log n). Unlike QuickSort, HeapSort has guaranteed O(n log n) worst case.",
|
|
16865
|
+
difficulty: "easy",
|
|
16866
|
+
topic: "HeapSort"
|
|
16867
|
+
},
|
|
16868
|
+
{
|
|
16869
|
+
id: "heap-6",
|
|
16870
|
+
question: "Which operation is NOT efficiently supported by a standard heap?",
|
|
16871
|
+
options: ["Find min/max", "Insert", "Delete min/max", "Search for arbitrary element"],
|
|
16872
|
+
correctAnswer: 3,
|
|
16873
|
+
explanation: "Heaps don't support efficient search - finding an arbitrary element requires O(n) time as you may need to scan the entire array. Heaps are optimized for min/max operations only.",
|
|
16874
|
+
hint: "A heap is not ordered like a BST.",
|
|
16875
|
+
difficulty: "medium",
|
|
16876
|
+
topic: "Limitations"
|
|
16877
|
+
},
|
|
16878
|
+
{
|
|
16879
|
+
id: "heap-7",
|
|
16880
|
+
question: "What is the space complexity of HeapSort?",
|
|
16881
|
+
options: ["O(1)", "O(log n)", "O(n)", "O(n log n)"],
|
|
16882
|
+
correctAnswer: 0,
|
|
16883
|
+
explanation: "HeapSort is an in-place sorting algorithm with O(1) extra space. The heap is built within the original array. Only O(log n) stack space is used if implemented recursively.",
|
|
16884
|
+
difficulty: "medium",
|
|
16885
|
+
topic: "Space Complexity"
|
|
16886
|
+
},
|
|
16887
|
+
{
|
|
16888
|
+
id: "heap-8",
|
|
16889
|
+
question: "In a min-heap with n elements, where can the maximum element be?",
|
|
16890
|
+
options: ["Only at the root", "Only at the last level", "At any leaf node", "Anywhere in the heap"],
|
|
16891
|
+
correctAnswer: 2,
|
|
16892
|
+
explanation: "In a min-heap, the maximum must be at a leaf node (it cannot have any children smaller than it). The maximum could be any of the ⌈n/2⌉ leaf nodes.",
|
|
16893
|
+
hint: "Think about the heap property and where max cannot be.",
|
|
16894
|
+
difficulty: "medium",
|
|
16895
|
+
topic: "Heap Property"
|
|
16896
|
+
},
|
|
16897
|
+
{
|
|
16898
|
+
id: "heap-9",
|
|
16899
|
+
question: "What data structure is typically used to implement a priority queue?",
|
|
16900
|
+
options: ["Sorted array", "Linked list", "Binary heap", "Hash table"],
|
|
16901
|
+
correctAnswer: 2,
|
|
16902
|
+
explanation: "Binary heaps are the standard implementation for priority queues because they provide O(log n) insert and extract-min/max operations. Sorted arrays have O(n) insert, and hash tables don't maintain order.",
|
|
16903
|
+
difficulty: "easy",
|
|
16904
|
+
topic: "Applications"
|
|
16905
|
+
},
|
|
16906
|
+
{
|
|
16907
|
+
id: "heap-10",
|
|
16908
|
+
question: "What is a Fibonacci heap's advantage over a binary heap?",
|
|
16909
|
+
options: [
|
|
16910
|
+
"Simpler implementation",
|
|
16911
|
+
"Better worst-case insert and decrease-key: O(1) amortized",
|
|
16912
|
+
"Uses less memory",
|
|
16913
|
+
"Faster extract-min operation"
|
|
16914
|
+
],
|
|
16915
|
+
correctAnswer: 1,
|
|
16916
|
+
explanation: "Fibonacci heaps have O(1) amortized insert and decrease-key operations (vs O(log n) for binary heaps). This makes them theoretically better for Dijkstra's algorithm, though binary heaps are often faster in practice due to constants.",
|
|
16917
|
+
difficulty: "hard",
|
|
16918
|
+
topic: "Advanced"
|
|
16919
|
+
}
|
|
16920
|
+
];
|
|
16921
|
+
function generateHeapSteps() {
|
|
16922
|
+
const steps = [];
|
|
16923
|
+
const heap = [];
|
|
16924
|
+
steps.push({
|
|
16925
|
+
operation: "init",
|
|
16926
|
+
array: [],
|
|
16927
|
+
heapSize: 0,
|
|
16928
|
+
description: "Initialize empty Max-Heap. Parent ≥ children."
|
|
16929
|
+
});
|
|
16930
|
+
for (const { op, value } of OPERATIONS$8) {
|
|
16931
|
+
if (op === "insert" && value !== void 0) {
|
|
16932
|
+
heap.push(value);
|
|
16933
|
+
let idx = heap.length - 1;
|
|
16934
|
+
steps.push({
|
|
16935
|
+
operation: "insert",
|
|
16936
|
+
array: [...heap],
|
|
16937
|
+
heapSize: heap.length,
|
|
16938
|
+
highlightIndex: idx,
|
|
16939
|
+
description: `insert(${value}): Add at index ${idx}`
|
|
16940
|
+
});
|
|
16941
|
+
while (idx > 0) {
|
|
16942
|
+
const parentIdx = Math.floor((idx - 1) / 2);
|
|
16943
|
+
steps.push({
|
|
16944
|
+
operation: "siftUp",
|
|
16945
|
+
array: [...heap],
|
|
16946
|
+
heapSize: heap.length,
|
|
16947
|
+
compareIndices: [idx, parentIdx],
|
|
16948
|
+
description: `Compare ${heap[idx]} with parent ${heap[parentIdx]}`
|
|
16949
|
+
});
|
|
16950
|
+
if (heap[idx] > heap[parentIdx]) {
|
|
16951
|
+
[heap[idx], heap[parentIdx]] = [heap[parentIdx], heap[idx]];
|
|
16952
|
+
steps.push({
|
|
16953
|
+
operation: "siftUp",
|
|
16954
|
+
array: [...heap],
|
|
16955
|
+
heapSize: heap.length,
|
|
16956
|
+
swapIndices: [idx, parentIdx],
|
|
16957
|
+
description: `${heap[parentIdx]} > ${heap[idx]}, swap!`
|
|
16958
|
+
});
|
|
16959
|
+
idx = parentIdx;
|
|
16960
|
+
} else {
|
|
16961
|
+
break;
|
|
16962
|
+
}
|
|
16963
|
+
}
|
|
16964
|
+
} else if (op === "extractMax") {
|
|
16965
|
+
if (heap.length === 0) continue;
|
|
16966
|
+
const max = heap[0];
|
|
16967
|
+
const last = heap.pop();
|
|
16968
|
+
if (heap.length === 0) {
|
|
16969
|
+
steps.push({
|
|
16970
|
+
operation: "extractMax",
|
|
16971
|
+
array: [],
|
|
16972
|
+
heapSize: 0,
|
|
16973
|
+
description: `extractMax() = ${max}, heap is now empty`
|
|
16974
|
+
});
|
|
16975
|
+
continue;
|
|
16976
|
+
}
|
|
16977
|
+
heap[0] = last;
|
|
16978
|
+
steps.push({
|
|
16979
|
+
operation: "extractMax",
|
|
16980
|
+
array: [...heap],
|
|
16981
|
+
heapSize: heap.length,
|
|
16982
|
+
highlightIndex: 0,
|
|
16983
|
+
description: `extractMax() = ${max}, move ${last} to root`
|
|
16984
|
+
});
|
|
16985
|
+
let idx = 0;
|
|
16986
|
+
while (true) {
|
|
16987
|
+
const left = 2 * idx + 1;
|
|
16988
|
+
const right = 2 * idx + 2;
|
|
16989
|
+
let largest = idx;
|
|
16990
|
+
if (left < heap.length && heap[left] > heap[largest]) {
|
|
16991
|
+
largest = left;
|
|
16992
|
+
}
|
|
16993
|
+
if (right < heap.length && heap[right] > heap[largest]) {
|
|
16994
|
+
largest = right;
|
|
16995
|
+
}
|
|
16996
|
+
if (largest === idx) break;
|
|
16997
|
+
steps.push({
|
|
16998
|
+
operation: "siftDown",
|
|
16999
|
+
array: [...heap],
|
|
17000
|
+
heapSize: heap.length,
|
|
17001
|
+
compareIndices: [idx, largest],
|
|
17002
|
+
description: `Compare ${heap[idx]} with larger child ${heap[largest]}`
|
|
17003
|
+
});
|
|
17004
|
+
[heap[idx], heap[largest]] = [heap[largest], heap[idx]];
|
|
17005
|
+
steps.push({
|
|
17006
|
+
operation: "siftDown",
|
|
17007
|
+
array: [...heap],
|
|
17008
|
+
heapSize: heap.length,
|
|
17009
|
+
swapIndices: [idx, largest],
|
|
17010
|
+
description: `Swap! ${heap[idx]} moved up`
|
|
17011
|
+
});
|
|
17012
|
+
idx = largest;
|
|
17013
|
+
}
|
|
17014
|
+
}
|
|
17015
|
+
}
|
|
17016
|
+
steps.push({
|
|
17017
|
+
operation: "done",
|
|
17018
|
+
array: [...heap],
|
|
17019
|
+
heapSize: heap.length,
|
|
17020
|
+
description: `Done! Heap has ${heap.length} elements. Max = ${heap[0] || "none"}`
|
|
17021
|
+
});
|
|
17022
|
+
return steps;
|
|
17023
|
+
}
|
|
17024
|
+
function getTreePositions(size) {
|
|
17025
|
+
const positions = [];
|
|
17026
|
+
const width = 280;
|
|
17027
|
+
for (let i = 0; i < size; i++) {
|
|
17028
|
+
const level = Math.floor(Math.log2(i + 1));
|
|
17029
|
+
const levelStart = Math.pow(2, level) - 1;
|
|
17030
|
+
const posInLevel = i - levelStart;
|
|
17031
|
+
const nodesInLevel = Math.pow(2, level);
|
|
17032
|
+
const spacing = width / (nodesInLevel + 1);
|
|
17033
|
+
positions.push({
|
|
17034
|
+
x: spacing * (posInLevel + 1),
|
|
17035
|
+
y: level * 50 + 25
|
|
17036
|
+
});
|
|
17037
|
+
}
|
|
17038
|
+
return positions;
|
|
17039
|
+
}
|
|
17040
|
+
const HeapInterviewVisualizerComponent = ({
|
|
17041
|
+
showControls = true,
|
|
17042
|
+
className = ""
|
|
17043
|
+
}) => {
|
|
17044
|
+
const { copyUrlToClipboard } = useUrlState({ prefix: "heap-int", scrollToId: VISUALIZER_ID });
|
|
17045
|
+
const [mode, setMode] = React.useState("visualize");
|
|
17046
|
+
const generateSteps = React.useMemo(() => generateHeapSteps, []);
|
|
17047
|
+
const playback = useVisualizerPlayback({ generateSteps });
|
|
17048
|
+
const interview = useInterviewMode({
|
|
17049
|
+
questions: HEAP_QUESTIONS,
|
|
17050
|
+
shuffleQuestions: true
|
|
17051
|
+
});
|
|
17052
|
+
const stepData = playback.currentStepData || {
|
|
17053
|
+
operation: "init",
|
|
17054
|
+
array: [],
|
|
17055
|
+
description: ""
|
|
17056
|
+
};
|
|
17057
|
+
const { array, highlightIndex, compareIndices, swapIndices, description } = stepData;
|
|
17058
|
+
const positions = getTreePositions(array.length);
|
|
17059
|
+
const getNodeStyle = (idx) => {
|
|
17060
|
+
if (swapIndices == null ? void 0 : swapIndices.includes(idx)) return "fill-green-400 stroke-green-500";
|
|
17061
|
+
if (compareIndices == null ? void 0 : compareIndices.includes(idx)) return "fill-amber-400 stroke-amber-500";
|
|
17062
|
+
if (idx === highlightIndex) return "fill-blue-200 stroke-blue-400";
|
|
17063
|
+
if (idx === 0) return "fill-orange-500 stroke-orange-600";
|
|
17064
|
+
return "fill-white stroke-gray-300";
|
|
17065
|
+
};
|
|
17066
|
+
const getTextColor = (idx) => {
|
|
17067
|
+
if ((swapIndices == null ? void 0 : swapIndices.includes(idx)) || idx === 0) return "white";
|
|
17068
|
+
return "#374151";
|
|
17069
|
+
};
|
|
17070
|
+
const handleShare = React.useCallback(async () => {
|
|
17071
|
+
return copyUrlToClipboard({ step: playback.currentStep });
|
|
17072
|
+
}, [copyUrlToClipboard, playback.currentStep]);
|
|
17073
|
+
const visualization = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
17074
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mb-4 p-3 bg-orange-50 rounded-lg border border-orange-200", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-sm text-orange-800 text-center", children: [
|
|
17075
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium", children: "Max-Heap Property:" }),
|
|
17076
|
+
" parent ≥ children"
|
|
17077
|
+
] }) }),
|
|
17078
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mb-4 bg-gray-50 rounded-lg p-2 min-h-[160px] flex items-center justify-center", children: array.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "280", height: Math.max(Math.floor(Math.log2(array.length)) * 50 + 60, 80), className: "mx-auto", children: [
|
|
17079
|
+
array.map((_, idx) => {
|
|
17080
|
+
if (idx === 0) return null;
|
|
17081
|
+
const parentIdx = Math.floor((idx - 1) / 2);
|
|
17082
|
+
const parentPos = positions[parentIdx];
|
|
17083
|
+
const childPos = positions[idx];
|
|
17084
|
+
if (!parentPos || !childPos) return null;
|
|
17085
|
+
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));
|
|
17086
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
17087
|
+
"line",
|
|
17088
|
+
{
|
|
17089
|
+
x1: parentPos.x,
|
|
17090
|
+
y1: parentPos.y,
|
|
17091
|
+
x2: childPos.x,
|
|
17092
|
+
y2: childPos.y,
|
|
17093
|
+
stroke: isActive ? "#f59e0b" : "#d1d5db",
|
|
17094
|
+
strokeWidth: isActive ? 2 : 1
|
|
17095
|
+
},
|
|
17096
|
+
`edge-${idx}`
|
|
17097
|
+
);
|
|
17098
|
+
}),
|
|
17099
|
+
array.map((val, idx) => {
|
|
17100
|
+
const pos = positions[idx];
|
|
17101
|
+
if (!pos) return null;
|
|
17102
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("g", { transform: `translate(${pos.x}, ${pos.y})`, children: [
|
|
17103
|
+
/* @__PURE__ */ jsxRuntime.jsx("circle", { r: "16", className: `${getNodeStyle(idx)} stroke-2` }),
|
|
17104
|
+
/* @__PURE__ */ jsxRuntime.jsx("text", { textAnchor: "middle", dy: "5", className: "text-xs font-bold", fill: getTextColor(idx), children: val })
|
|
17105
|
+
] }, idx);
|
|
17106
|
+
})
|
|
17107
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-gray-400 text-sm", children: "Empty heap" }) }),
|
|
17108
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-4 p-3 bg-gray-100 rounded-lg min-h-[60px]", children: [
|
|
17109
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xs text-gray-600 mb-1", children: "Array: " }),
|
|
17110
|
+
array.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex gap-1 flex-wrap", children: array.map((val, idx) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
17111
|
+
"div",
|
|
17112
|
+
{
|
|
17113
|
+
className: `w-8 h-8 flex items-center justify-center rounded text-xs font-mono ${(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 === 0 ? "bg-orange-500 text-white" : "bg-white border border-gray-300"}`,
|
|
17114
|
+
children: val
|
|
17115
|
+
},
|
|
17116
|
+
idx
|
|
17117
|
+
)) }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-gray-400 text-xs italic", children: "Elements will appear here..." })
|
|
17118
|
+
] })
|
|
17119
|
+
] });
|
|
17120
|
+
const modeToggle = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-1 bg-gray-200 rounded-lg p-0.5", children: [
|
|
17121
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
17122
|
+
"button",
|
|
17123
|
+
{
|
|
17124
|
+
onClick: () => setMode("visualize"),
|
|
17125
|
+
className: `px-3 py-1 rounded-md text-xs font-medium transition-colors ${mode === "visualize" ? "bg-white text-orange-600 shadow-sm" : "text-gray-600 hover:text-gray-800"}`,
|
|
17126
|
+
children: "Visualize"
|
|
17127
|
+
}
|
|
17128
|
+
),
|
|
17129
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
17130
|
+
"button",
|
|
17131
|
+
{
|
|
17132
|
+
onClick: () => setMode("interview"),
|
|
17133
|
+
className: `px-3 py-1 rounded-md text-xs font-medium transition-colors ${mode === "interview" ? "bg-white text-orange-600 shadow-sm" : "text-gray-600 hover:text-gray-800"}`,
|
|
17134
|
+
children: "Interview"
|
|
17135
|
+
}
|
|
17136
|
+
)
|
|
17137
|
+
] });
|
|
17138
|
+
const sidePanel = mode === "interview" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
17139
|
+
InterviewModePanel,
|
|
17140
|
+
{
|
|
17141
|
+
currentQuestion: interview.currentQuestion,
|
|
17142
|
+
currentQuestionIndex: interview.session.currentQuestionIndex,
|
|
17143
|
+
totalQuestions: interview.session.questions.length,
|
|
17144
|
+
selectedAnswer: interview.selectedAnswer,
|
|
17145
|
+
showExplanation: interview.showExplanation,
|
|
17146
|
+
showHint: interview.showHint,
|
|
17147
|
+
isAnswered: interview.isAnswered,
|
|
17148
|
+
isComplete: interview.isComplete,
|
|
17149
|
+
score: interview.score,
|
|
17150
|
+
onSelectAnswer: interview.selectAnswer,
|
|
17151
|
+
onNextQuestion: interview.nextQuestion,
|
|
17152
|
+
onPreviousQuestion: interview.previousQuestion,
|
|
17153
|
+
onUseHint: interview.useHint,
|
|
17154
|
+
onRestart: interview.restartSession,
|
|
17155
|
+
accentColor: "orange"
|
|
17156
|
+
}
|
|
17157
|
+
) : void 0;
|
|
17158
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
17159
|
+
BaseVisualizerLayout,
|
|
17160
|
+
{
|
|
17161
|
+
id: VISUALIZER_ID,
|
|
17162
|
+
title: "Heap (Interview Mode)",
|
|
17163
|
+
badges: BADGES$e,
|
|
17164
|
+
gradient: "orange",
|
|
17165
|
+
className,
|
|
17166
|
+
minHeight: 450,
|
|
17167
|
+
onShare: handleShare,
|
|
17168
|
+
headerExtra: modeToggle,
|
|
17169
|
+
status: {
|
|
17170
|
+
description,
|
|
17171
|
+
currentStep: playback.currentStep,
|
|
17172
|
+
totalSteps: playback.steps.length,
|
|
17173
|
+
variant: stepData.operation === "done" ? "success" : swapIndices ? "warning" : "default"
|
|
17174
|
+
},
|
|
17175
|
+
controls: {
|
|
17176
|
+
isPlaying: playback.isPlaying,
|
|
17177
|
+
currentStep: playback.currentStep,
|
|
17178
|
+
totalSteps: playback.steps.length,
|
|
17179
|
+
speed: playback.speed,
|
|
17180
|
+
onPlayPause: playback.handlePlayPause,
|
|
17181
|
+
onStep: playback.handleStep,
|
|
17182
|
+
onStepBack: playback.handleStepBack,
|
|
17183
|
+
onReset: playback.handleReset,
|
|
17184
|
+
onSpeedChange: playback.setSpeed,
|
|
17185
|
+
accentColor: "orange"
|
|
17186
|
+
},
|
|
17187
|
+
showControls,
|
|
17188
|
+
legendItems: LEGEND_ITEMS$e,
|
|
17189
|
+
sidePanel,
|
|
17190
|
+
children: visualization
|
|
17191
|
+
}
|
|
17192
|
+
);
|
|
17193
|
+
};
|
|
17194
|
+
const HeapInterviewVisualizer = React.memo(HeapInterviewVisualizerComponent);
|
|
16798
17195
|
const SEGMENT_COUNT = 4;
|
|
16799
17196
|
const OPERATIONS$7 = [
|
|
16800
17197
|
{ thread: "T1", op: "put", key: "Alice", value: 100 },
|
|
@@ -22822,6 +23219,7 @@ exports.GraphVisualizer = GraphVisualizer;
|
|
|
22822
23219
|
exports.HashMapInterviewVisualizer = HashMapInterviewVisualizer;
|
|
22823
23220
|
exports.HashMapVisualizer = HashMapVisualizer;
|
|
22824
23221
|
exports.HashTableVisualizer = HashTableVisualizer;
|
|
23222
|
+
exports.HeapInterviewVisualizer = HeapInterviewVisualizer;
|
|
22825
23223
|
exports.HeapVisualizer = HeapVisualizer;
|
|
22826
23224
|
exports.HelpPanel = HelpPanel;
|
|
22827
23225
|
exports.ImmutableCollectionsVisualizer = ImmutableCollectionsVisualizer;
|