forked from prepguides/prepguides.dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-bst.html
More file actions
61 lines (55 loc) · 1.92 KB
/
test-bst.html
File metadata and controls
61 lines (55 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Test BST</title>
<script src="https://d3js.org/d3.v7.min.js"></script>
<style>
body { font-family: Arial, sans-serif; padding: 20px; }
.controls { margin-bottom: 20px; }
button { margin: 5px; padding: 10px; }
#treeSvg { border: 1px solid #ccc; }
</style>
</head>
<body>
<h1>BST Test</h1>
<div class="controls">
<button onclick="testBST()">Test BST</button>
<button onclick="generateTree()">Generate Tree</button>
</div>
<svg id="treeSvg" width="800" height="500"></svg>
<script>
console.log('D3.js loaded:', typeof d3 !== 'undefined');
function testBST() {
console.log('Testing BST...');
const svg = d3.select('#treeSvg');
console.log('SVG selected:', svg.empty() ? 'NO' : 'YES');
svg.append('circle')
.attr('cx', 100)
.attr('cy', 100)
.attr('r', 20)
.style('fill', 'blue');
console.log('Circle added');
}
function generateTree() {
console.log('Generating tree...');
if (window.bstVisualizer) {
window.bstVisualizer.generateRandomTree();
} else {
console.error('BST Visualizer not available');
}
}
// Load the BST visualizer
const script = document.createElement('script');
script.src = 'algorithms/code/bst-visualizer.js';
script.onload = () => {
console.log('BST Visualizer script loaded');
};
script.onerror = () => {
console.error('Failed to load BST Visualizer script');
};
document.head.appendChild(script);
</script>
</body>
</html>