podsni commited on
Commit
d961f8b
·
verified ·
1 Parent(s): 7d9f55e

Animation 3blue1Brows buatakan agar menjadi generator untuk menjelaskan tentang algorthm

Browse files
Files changed (5) hide show
  1. README.md +7 -4
  2. dynamic.html +332 -0
  3. graph.html +304 -0
  4. index.html +367 -18
  5. sorting.html +251 -0
README.md CHANGED
@@ -1,10 +1,13 @@
1
  ---
2
  title: Algorithm Animator
3
- emoji: 📈
4
- colorFrom: indigo
5
- colorTo: yellow
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
1
  ---
2
  title: Algorithm Animator
3
+ colorFrom: yellow
4
+ colorTo: pink
5
+ emoji: 🐳
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - deepsite-v3
10
  ---
11
 
12
+ # Welcome to your new DeepSite project!
13
+ This project was created with [DeepSite](https://deepsite.hf.co).
dynamic.html ADDED
@@ -0,0 +1,332 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Dynamic Programming - Algorithm Animator</title>
7
+ <link rel="icon" type="image/x-icon" href="/static/favicon.ico">
8
+ <script src="https://cdn.tailwindcss.com"></script>
9
+ <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
10
+ <script src="https://unpkg.com/feather-icons"></script>
11
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML" async></script>
12
+ <style>
13
+ body {
14
+ background-color: #0f172a;
15
+ color: #e2e8f0;
16
+ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
17
+ }
18
+
19
+ .algorithm-selector {
20
+ background-color: #1e293b;
21
+ border-radius: 8px;
22
+ transition: all 0.3s ease;
23
+ }
24
+
25
+ .algorithm-selector:hover {
26
+ background-color: #334155;
27
+ }
28
+
29
+ .active-algorithm {
30
+ background-color: #334155;
31
+ border-left: 4px solid #a78bfa;
32
+ }
33
+
34
+ .visualization-area {
35
+ background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
36
+ border-radius: 12px;
37
+ box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
38
+ }
39
+
40
+ .dp-table {
41
+ border-collapse: separate;
42
+ border-spacing: 0;
43
+ }
44
+
45
+ .dp-cell {
46
+ width: 50px;
47
+ height: 50px;
48
+ border: 1px solid #475569;
49
+ text-align: center;
50
+ vertical-align: middle;
51
+ background-color: #1e293b;
52
+ transition: all 0.3s ease;
53
+ }
54
+
55
+ .dp-cell.calculated {
56
+ background-color: #4f46e5;
57
+ color: white;
58
+ }
59
+
60
+ .dp-cell.current {
61
+ background-color: #7c3aed;
62
+ color: white;
63
+ transform: scale(1.1);
64
+ box-shadow: 0 0 10px rgba(124, 58, 237, 0.5);
65
+ }
66
+
67
+ .dp-cell.final {
68
+ background-color: #10b981;
69
+ color: white;
70
+ }
71
+
72
+ .code-block {
73
+ background-color: #1e293b;
74
+ border-left: 4px solid #a78bfa;
75
+ font-family: 'Fira Code', monospace;
76
+ }
77
+
78
+ .complexity-badge {
79
+ background-color: #334155;
80
+ }
81
+ </style>
82
+ </head>
83
+ <body class="min-h-screen">
84
+ <!-- Navigation -->
85
+ <nav class="bg-slate-900 border-b border-slate-700 sticky top-0 z-50">
86
+ <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
87
+ <div class="flex items-center justify-between h-16">
88
+ <div class="flex items-center">
89
+ <div class="flex-shrink-0 flex items-center">
90
+ <i data-feather="cpu" class="text-blue-400 mr-2"></i>
91
+ <span class="font-bold text-xl text-white">Algorithm Animator</span>
92
+ </div>
93
+ <div class="hidden md:block">
94
+ <div class="ml-10 flex items-baseline space-x-4">
95
+ <a href="index.html" class="text-gray-300 hover:text-white px-3 py-2 rounded-md text-sm font-medium">Home</a>
96
+ <a href="sorting.html" class="text-gray-300 hover:text-white px-3 py-2 rounded-md text-sm font-medium">Sorting</a>
97
+ <a href="graph.html" class="text-gray-300 hover:text-white px-3 py-2 rounded-md text-sm font-medium">Graph Algorithms</a>
98
+ <a href="#" class="text-white px-3 py-2 rounded-md text-sm font-medium">Dynamic Programming</a>
99
+ </div>
100
+ </div>
101
+ </div>
102
+ </div>
103
+ </div>
104
+ </nav>
105
+
106
+ <!-- Main Content -->
107
+ <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
108
+ <div class="text-center mb-10">
109
+ <h1 class="text-3xl font-extrabold text-white sm:text-4xl">
110
+ Dynamic Programming Visualization
111
+ </h1>
112
+ <p class="mt-3 max-w-2xl mx-auto text-xl text-gray-300">
113
+ Understand how dynamic programming solves complex problems by breaking them into simpler subproblems
114
+ </p>
115
+ </div>
116
+
117
+ <div class="flex flex-col lg:flex-row gap-8">
118
+ <!-- Algorithm Selection Panel -->
119
+ <div class="lg:w-1/4">
120
+ <div class="bg-slate-800 rounded-lg p-6 sticky top-24">
121
+ <h2 class="text-xl font-bold text-white mb-4">DP Problems</h2>
122
+ <div class="space-y-3">
123
+ <div class="algorithm-selector p-4 cursor-pointer active-algorithm">
124
+ <h3 class="font-medium text-white">Fibonacci Sequence</h3>
125
+ <p class="text-sm text-gray-300 mt-1">Classic recursive problem with overlapping subproblems</p>
126
+ </div>
127
+ <div class="algorithm-selector p-4 cursor-pointer">
128
+ <h3 class="font-medium text-white">0/1 Knapsack</h3>
129
+ <p class="text-sm text-gray-300 mt-1">Optimization problem with capacity constraints</p>
130
+ </div>
131
+ <div class="algorithm-selector p-4 cursor-pointer">
132
+ <h3 class="font-medium text-white">Longest Common Subsequence</h3>
133
+ <p class="text-sm text-gray-300 mt-1">Finding longest sequence common to both strings</p>
134
+ </div>
135
+ <div class="algorithm-selector p-4 cursor-pointer">
136
+ <h3 class="font-medium text-white">Matrix Chain Multiplication</h3>
137
+ <p class="text-sm text-gray-300 mt-1">Minimizing scalar multiplications</p>
138
+ </div>
139
+ <div class="algorithm-selector p-4 cursor-pointer">
140
+ <h3 class="font-medium text-white">Coin Change</h3>
141
+ <p class="text-sm text-gray-300 mt-1">Finding minimum coins for a given amount</p>
142
+ </div>
143
+ </div>
144
+
145
+ <div class="mt-8">
146
+ <h3 class="font-medium text-white mb-3">Controls</h3>
147
+ <div class="grid grid-cols-2 gap-3">
148
+ <button class="bg-purple-600 hover:bg-purple-700 text-white py-2 px-4 rounded">
149
+ Play
150
+ </button>
151
+ <button class="bg-slate-700 hover:bg-slate-600 text-white py-2 px-4 rounded">
152
+ Pause
153
+ </button>
154
+ <button class="bg-slate-700 hover:bg-slate-600 text-white py-2 px-4 rounded">
155
+ Reset
156
+ </button>
157
+ <button class="bg-slate-700 hover:bg-slate-600 text-white py-2 px-4 rounded">
158
+ Step
159
+ </button>
160
+ </div>
161
+ </div>
162
+
163
+ <div class="mt-8">
164
+ <h3 class="font-medium text-white mb-3">Problem Parameters</h3>
165
+ <div class="space-y-3">
166
+ <div>
167
+ <label class="text-sm text-gray-300">Sequence Length</label>
168
+ <input type="range" min="5" max="20" value="10" class="w-full mt-1">
169
+ </div>
170
+ <div>
171
+ <label class="text-sm text-gray-300">Show Memoization Table</label>
172
+ <div class="mt-1">
173
+ <label class="inline-flex items-center">
174
+ <input type="checkbox" class="rounded text-purple-500" checked>
175
+ <span class="ml-2">Enabled</span>
176
+ </label>
177
+ </div>
178
+ </div>
179
+ </div>
180
+ </div>
181
+ </div>
182
+ </div>
183
+
184
+ <!-- Visualization Area -->
185
+ <div class="lg:w-3/4">
186
+ <div class="visualization-area p-6 rounded-xl">
187
+ <div class="flex justify-between items-center mb-6">
188
+ <h2 class="text-2xl font-bold text-white">Fibonacci Sequence Visualization</h2>
189
+ <div class="flex space-x-3">
190
+ <div class="complexity-badge px-3 py-1 rounded-full text-sm">
191
+ Time: O(n)
192
+ </div>
193
+ <div class="complexity-badge px-3 py-1 rounded-full text-sm">
194
+ Space: O(n)
195
+ </div>
196
+ </div>
197
+ </div>
198
+
199
+ <!-- Fibonacci Sequence Visualization -->
200
+ <div class="mb-8">
201
+ <h3 class="font-bold text-white mb-4">Computing Fibonacci(6)</h3>
202
+ <div class="bg-slate-800 rounded-lg p-6">
203
+ <div class="overflow-x-auto">
204
+ <table class="dp-table mx-auto">
205
+ <thead>
206
+ <tr>
207
+ <th class="dp-cell font-bold">n</th>
208
+ <th class="dp-cell font-bold">0</th>
209
+ <th class="dp-cell font-bold">1</th>
210
+ <th class="dp-cell font-bold">2</th>
211
+ <th class="dp-cell font-bold">3</th>
212
+ <th class="dp-cell font-bold">4</th>
213
+ <th class="dp-cell font-bold">5</th>
214
+ <th class="dp-cell font-bold">6</th>
215
+ </tr>
216
+ </thead>
217
+ <tbody>
218
+ <tr>
219
+ <td class="dp-cell font-bold">fib(n)</td>
220
+ <td class="dp-cell calculated">0</td>
221
+ <td class="dp-cell calculated">1</td>
222
+ <td class="dp-cell calculated">1</td>
223
+ <td class="dp-cell calculated">2</td>
224
+ <td class="dp-cell calculated">3</td>
225
+ <td class="dp-cell current">5</td>
226
+ <td class="dp-cell">8</td>
227
+ </tr>
228
+ </tbody>
229
+ </table>
230
+ </div>
231
+
232
+ <div class="mt-6 text-center">
233
+ <div class="inline-block bg-purple-900 px-4 py-2 rounded-lg">
234
+ <span class="text-purple-300">fib(6) = fib(5) + fib(4) = 5 + 3 = </span>
235
+ <span class="text-white font-bold text-xl">8</span>
236
+ </div>
237
+ </div>
238
+ </div>
239
+ </div>
240
+
241
+ <!-- Recursion Tree -->
242
+ <div class="mb-8">
243
+ <h3 class="font-bold text-white mb-4">Recursion Tree Visualization</h3>
244
+ <div class="bg-slate-800 rounded-lg p-6 h-64 flex items-center justify-center">
245
+ <div class="text-center">
246
+ <div class="text-white font-mono text-lg mb-2">fib(6)</div>
247
+ <div class="flex justify-center space-x-8">
248
+ <div class="text-center">
249
+ <div class="text-blue-300 font-mono">fib(5)</div>
250
+ <div class="text-xs text-gray-400 mt-1">Calculated</div>
251
+ </div>
252
+ <div class="text-center">
253
+ <div class="text-purple-300 font-mono">fib(4)</div>
254
+ <div class="text-xs text-gray-400 mt-1">Calculated</div>
255
+ </div>
256
+ </div>
257
+ <div class="mt-4 text-sm text-gray-400">
258
+ Using memoization to avoid redundant calculations
259
+ </div>
260
+ </div>
261
+ </div>
262
+ </div>
263
+
264
+ <!-- Current Step Description -->
265
+ <div class="bg-slate-800 rounded-lg p-4 mb-6">
266
+ <h3 class="font-bold text-white mb-2">Current Step</h3>
267
+ <p class="text-gray-300">Calculating fib(6) by adding previously computed values fib(5)=5 and fib(4)=3.</p>
268
+ </div>
269
+
270
+ <!-- Pseudocode -->
271
+ <div class="code-block p-4 rounded mb-6">
272
+ <h3 class="font-bold text-white mb-2">Memoized Fibonacci</h3>
273
+ <pre class="text-green-400 text-sm">
274
+ def fibonacci(n, memo={}):
275
+ if n in memo:
276
+ return memo[n]
277
+
278
+ if n <= 1:
279
+ return n
280
+
281
+ memo[n] = fibonacci(n-1, memo) + fibonacci(n-2, memo)
282
+ return memo[n]</pre>
283
+ </div>
284
+
285
+ <!-- Mathematical Explanation -->
286
+ <div class="bg-slate-800 rounded-lg p-4">
287
+ <h3 class="font-bold text-white mb-3">Mathematical Analysis</h3>
288
+ <div class="math-display text-purple-300">
289
+ \( F(n) = F(n-1) + F(n-2) \text{ for } n > 1 \)
290
+ </div>
291
+ <p class="text-gray-300 mt-3">
292
+ The Fibonacci sequence exhibits optimal substructure and overlapping subproblems,
293
+ making it ideal for dynamic programming optimization.
294
+ </p>
295
+ <div class="math-display text-purple-300">
296
+ \( \text{Time Complexity: } O(n) \text{ with memoization} \)
297
+ </div>
298
+ <p class="text-gray-300 mt-3">
299
+ Without memoization, the naive recursive approach has exponential time complexity
300
+ \( O(\phi^n) \) where \( \phi \) is the golden ratio. Memoization reduces this to
301
+ linear time by storing previously computed values.
302
+ </p>
303
+ </div>
304
+ </div>
305
+ </div>
306
+ </div>
307
+ </div>
308
+
309
+ <!-- Footer -->
310
+ <footer class="bg-slate-900 border-t border-slate-800 mt-12">
311
+ <div class="max-w-7xl mx-auto py-12 px-4 sm:px-6 lg:px-8">
312
+ <div class="md:flex md:items-center md:justify-between">
313
+ <div class="flex justify-center md:justify-start">
314
+ <div class="flex items-center">
315
+ <i data-feather="cpu" class="text-blue-400 mr-2"></i>
316
+ <span class="text-white font-bold">Algorithm Animator</span>
317
+ </div>
318
+ </div>
319
+ <div class="mt-8 md:mt-0 md:order-1">
320
+ <p class="text-center text-base text-gray-400">
321
+ &copy; 2023 Algorithm Animator. All rights reserved.
322
+ </p>
323
+ </div>
324
+ </div>
325
+ </div>
326
+ </footer>
327
+
328
+ <script>
329
+ feather.replace();
330
+ </script>
331
+ </body>
332
+ </html>
graph.html ADDED
@@ -0,0 +1,304 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Graph Algorithms - Algorithm Animator</title>
7
+ <link rel="icon" type="image/x-icon" href="/static/favicon.ico">
8
+ <script src="https://cdn.tailwindcss.com"></script>
9
+ <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
10
+ <script src="https://unpkg.com/feather-icons"></script>
11
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML" async></script>
12
+ <style>
13
+ body {
14
+ background-color: #0f172a;
15
+ color: #e2e8f0;
16
+ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
17
+ }
18
+
19
+ .algorithm-selector {
20
+ background-color: #1e293b;
21
+ border-radius: 8px;
22
+ transition: all 0.3s ease;
23
+ }
24
+
25
+ .algorithm-selector:hover {
26
+ background-color: #334155;
27
+ }
28
+
29
+ .active-algorithm {
30
+ background-color: #334155;
31
+ border-left: 4px solid #34d399;
32
+ }
33
+
34
+ .visualization-area {
35
+ background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
36
+ border-radius: 12px;
37
+ box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
38
+ }
39
+
40
+ .node {
41
+ fill: #60a5fa;
42
+ stroke: #93c5fd;
43
+ stroke-width: 2px;
44
+ transition: all 0.3s ease;
45
+ }
46
+
47
+ .node.visited {
48
+ fill: #34d399;
49
+ stroke: #6ee7b7;
50
+ }
51
+
52
+ .node.current {
53
+ fill: #fbbf24;
54
+ stroke: #fcd34d;
55
+ }
56
+
57
+ .edge {
58
+ stroke: #64748b;
59
+ stroke-width: 2;
60
+ }
61
+
62
+ .edge.visited {
63
+ stroke: #34d399;
64
+ stroke-width: 3;
65
+ }
66
+
67
+ .edge.current {
68
+ stroke: #fbbf24;
69
+ stroke-width: 3;
70
+ }
71
+
72
+ .code-block {
73
+ background-color: #1e293b;
74
+ border-left: 4px solid #34d399;
75
+ font-family: 'Fira Code', monospace;
76
+ }
77
+
78
+ .complexity-badge {
79
+ background-color: #334155;
80
+ }
81
+ </style>
82
+ </head>
83
+ <body class="min-h-screen">
84
+ <!-- Navigation -->
85
+ <nav class="bg-slate-900 border-b border-slate-700 sticky top-0 z-50">
86
+ <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
87
+ <div class="flex items-center justify-between h-16">
88
+ <div class="flex items-center">
89
+ <div class="flex-shrink-0 flex items-center">
90
+ <i data-feather="cpu" class="text-blue-400 mr-2"></i>
91
+ <span class="font-bold text-xl text-white">Algorithm Animator</span>
92
+ </div>
93
+ <div class="hidden md:block">
94
+ <div class="ml-10 flex items-baseline space-x-4">
95
+ <a href="index.html" class="text-gray-300 hover:text-white px-3 py-2 rounded-md text-sm font-medium">Home</a>
96
+ <a href="sorting.html" class="text-gray-300 hover:text-white px-3 py-2 rounded-md text-sm font-medium">Sorting</a>
97
+ <a href="#" class="text-white px-3 py-2 rounded-md text-sm font-medium">Graph Algorithms</a>
98
+ <a href="dynamic.html" class="text-gray-300 hover:text-white px-3 py-2 rounded-md text-sm font-medium">Dynamic Programming</a>
99
+ </div>
100
+ </div>
101
+ </div>
102
+ </div>
103
+ </div>
104
+ </nav>
105
+
106
+ <!-- Main Content -->
107
+ <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
108
+ <div class="text-center mb-10">
109
+ <h1 class="text-3xl font-extrabold text-white sm:text-4xl">
110
+ Graph Algorithms Visualization
111
+ </h1>
112
+ <p class="mt-3 max-w-2xl mx-auto text-xl text-gray-300">
113
+ Explore fundamental graph algorithms through interactive visualizations
114
+ </p>
115
+ </div>
116
+
117
+ <div class="flex flex-col lg:flex-row gap-8">
118
+ <!-- Algorithm Selection Panel -->
119
+ <div class="lg:w-1/4">
120
+ <div class="bg-slate-800 rounded-lg p-6 sticky top-24">
121
+ <h2 class="text-xl font-bold text-white mb-4">Graph Algorithms</h2>
122
+ <div class="space-y-3">
123
+ <div class="algorithm-selector p-4 cursor-pointer active-algorithm">
124
+ <h3 class="font-medium text-white">Breadth-First Search</h3>
125
+ <p class="text-sm text-gray-300 mt-1">Level-order traversal algorithm</p>
126
+ </div>
127
+ <div class="algorithm-selector p-4 cursor-pointer">
128
+ <h3 class="font-medium text-white">Depth-First Search</h3>
129
+ <p class="text-sm text-gray-300 mt-1">Recursive traversal algorithm</p>
130
+ </div>
131
+ <div class="algorithm-selector p-4 cursor-pointer">
132
+ <h3 class="font-medium text-white">Dijkstra's Algorithm</h3>
133
+ <p class="text-sm text-gray-300 mt-1">Shortest path in weighted graphs</p>
134
+ </div>
135
+ <div class="algorithm-selector p-4 cursor-pointer">
136
+ <h3 class="font-medium text-white">Prim's Algorithm</h3>
137
+ <p class="text-sm text-gray-300 mt-1">Minimum spanning tree</p>
138
+ </div>
139
+ <div class="algorithm-selector p-4 cursor-pointer">
140
+ <h3 class="font-medium text-white">Kruskal's Algorithm</h3>
141
+ <p class="text-sm text-gray-300 mt-1">Minimum spanning forest</p>
142
+ </div>
143
+ </div>
144
+
145
+ <div class="mt-8">
146
+ <h3 class="font-medium text-white mb-3">Controls</h3>
147
+ <div class="grid grid-cols-2 gap-3">
148
+ <button class="bg-green-600 hover:bg-green-700 text-white py-2 px-4 rounded">
149
+ Play
150
+ </button>
151
+ <button class="bg-slate-700 hover:bg-slate-600 text-white py-2 px-4 rounded">
152
+ Pause
153
+ </button>
154
+ <button class="bg-slate-700 hover:bg-slate-600 text-white py-2 px-4 rounded">
155
+ Reset
156
+ </button>
157
+ <button class="bg-slate-700 hover:bg-slate-600 text-white py-2 px-4 rounded">
158
+ Step
159
+ </button>
160
+ </div>
161
+ </div>
162
+
163
+ <div class="mt-8">
164
+ <h3 class="font-medium text-white mb-3">Graph Type</h3>
165
+ <select class="w-full bg-slate-700 text-white rounded p-2">
166
+ <option>Undirected Graph</option>
167
+ <option>Directed Graph</option>
168
+ <option>Weighted Graph</option>
169
+ </select>
170
+ </div>
171
+ </div>
172
+ </div>
173
+
174
+ <!-- Visualization Area -->
175
+ <div class="lg:w-3/4">
176
+ <div class="visualization-area p-6 rounded-xl">
177
+ <div class="flex justify-between items-center mb-6">
178
+ <h2 class="text-2xl font-bold text-white">Breadth-First Search Visualization</h2>
179
+ <div class="flex space-x-3">
180
+ <div class="complexity-badge px-3 py-1 rounded-full text-sm">
181
+ Time: O(V + E)
182
+ </div>
183
+ <div class="complexity-badge px-3 py-1 rounded-full text-sm">
184
+ Space: O(V)
185
+ </div>
186
+ </div>
187
+ </div>
188
+
189
+ <!-- Graph Visualization -->
190
+ <div class="mb-8">
191
+ <div class="bg-slate-800 rounded-lg p-6 h-96 flex items-center justify-center">
192
+ <!-- SVG Graph Visualization -->
193
+ <svg width="100%" height="100%" viewBox="0 0 600 300">
194
+ <!-- Edges -->
195
+ <line x1="100" y1="150" x2="200" y2="100" class="edge visited"></line>
196
+ <line x1="200" y1="100" x2="300" y2="150" class="edge current"></line>
197
+ <line x1="300" y1="150" x2="400" y2="100" class="edge"></line>
198
+ <line x1="100" y1="150" x2="200" y2="200" class="edge"></line>
199
+ <line x1="200" y1="200" x2="300" y2="150" class="edge visited"></line>
200
+ <line x1="300" y1="150" x2="400" y2="200" class="edge"></line>
201
+
202
+ <!-- Nodes -->
203
+ <circle cx="100" cy="150" r="20" class="node visited"></circle>
204
+ <circle cx="200" cy="100" r="20" class="node visited"></circle>
205
+ <circle cx="300" cy="150" r="20" class="node current"></circle>
206
+ <circle cx="400" cy="100" r="20" class="node"></circle>
207
+ <circle cx="200" cy="200" r="20" class="node visited"></circle>
208
+ <circle cx="400" cy="200" r="20" class="node"></circle>
209
+
210
+ <!-- Node Labels -->
211
+ <text x="100" y="155" text-anchor="middle" class="text-white font-bold">A</text>
212
+ <text x="200" y="105" text-anchor="middle" class="text-white font-bold">B</text>
213
+ <text x="300" y="155" text-anchor="middle" class="text-white font-bold">C</text>
214
+ <text x="400" y="105" text-anchor="middle" class="text-white font-bold">D</text>
215
+ <text x="200" y="205" text-anchor="middle" class="text-white font-bold">E</text>
216
+ <text x="400" y="205" text-anchor="middle" class="text-white font-bold">F</text>
217
+ </svg>
218
+ </div>
219
+ </div>
220
+
221
+ <!-- Current Step Description -->
222
+ <div class="bg-slate-800 rounded-lg p-4 mb-6">
223
+ <h3 class="font-bold text-white mb-2">Current Step</h3>
224
+ <p class="text-gray-300">Visiting node C. Adding its unvisited neighbors D and F to the queue.</p>
225
+ </div>
226
+
227
+ <!-- Queue Visualization -->
228
+ <div class="bg-slate-800 rounded-lg p-4 mb-6">
229
+ <h3 class="font-bold text-white mb-2">BFS Queue</h3>
230
+ <div class="flex space-x-2">
231
+ <div class="bg-blue-500 px-3 py-1 rounded">D</div>
232
+ <div class="bg-blue-500 px-3 py-1 rounded">F</div>
233
+ <div class="bg-gray-700 px-3 py-1 rounded text-gray-400">Empty</div>
234
+ <div class="bg-gray-700 px-3 py-1 rounded text-gray-400">Empty</div>
235
+ </div>
236
+ </div>
237
+
238
+ <!-- Pseudocode -->
239
+ <div class="code-block p-4 rounded mb-6">
240
+ <h3 class="font-bold text-white mb-2">Pseudocode</h3>
241
+ <pre class="text-green-400 text-sm">
242
+ BFS(graph, start):
243
+ queue = [start]
244
+ visited = set([start])
245
+
246
+ while queue:
247
+ node = queue.pop(0)
248
+ process(node)
249
+
250
+ for neighbor in graph[node]:
251
+ if neighbor not in visited:
252
+ visited.add(neighbor)
253
+ queue.append(neighbor)</pre>
254
+ </div>
255
+
256
+ <!-- Mathematical Explanation -->
257
+ <div class="bg-slate-800 rounded-lg p-4">
258
+ <h3 class="font-bold text-white mb-3">Mathematical Analysis</h3>
259
+ <div class="math-display text-green-300">
260
+ \( \text{Time Complexity: } O(V + E) \)
261
+ </div>
262
+ <p class="text-gray-300 mt-3">
263
+ BFS visits each vertex exactly once and examines each edge exactly twice
264
+ (once from each endpoint in undirected graphs). Therefore, the time complexity
265
+ is proportional to the sum of vertices and edges.
266
+ </p>
267
+ <div class="math-display text-green-300">
268
+ \( \text{Space Complexity: } O(V) \)
269
+ </div>
270
+ <p class="text-gray-300 mt-3">
271
+ The space complexity is determined by the maximum size of the queue, which
272
+ can contain at most \( V-1 \) vertices in the worst case (when all but one
273
+ vertex are at the same level of the BFS tree).
274
+ </p>
275
+ </div>
276
+ </div>
277
+ </div>
278
+ </div>
279
+ </div>
280
+
281
+ <!-- Footer -->
282
+ <footer class="bg-slate-900 border-t border-slate-800 mt-12">
283
+ <div class="max-w-7xl mx-auto py-12 px-4 sm:px-6 lg:px-8">
284
+ <div class="md:flex md:items-center md:justify-between">
285
+ <div class="flex justify-center md:justify-start">
286
+ <div class="flex items-center">
287
+ <i data-feather="cpu" class="text-blue-400 mr-2"></i>
288
+ <span class="text-white font-bold">Algorithm Animator</span>
289
+ </div>
290
+ </div>
291
+ <div class="mt-8 md:mt-0 md:order-1">
292
+ <p class="text-center text-base text-gray-400">
293
+ &copy; 2023 Algorithm Animator. All rights reserved.
294
+ </p>
295
+ </div>
296
+ </div>
297
+ </div>
298
+ </footer>
299
+
300
+ <script>
301
+ feather.replace();
302
+ </script>
303
+ </body>
304
+ </html>
index.html CHANGED
@@ -1,19 +1,368 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  </html>
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Algorithm Animator</title>
7
+ <link rel="icon" type="image/x-icon" href="/static/favicon.ico">
8
+ <script src="https://cdn.tailwindcss.com"></script>
9
+ <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
10
+ <script src="https://unpkg.com/feather-icons"></script>
11
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML" async></script>
12
+ <style>
13
+ :root {
14
+ --primary-color: #2d3748;
15
+ --secondary-color: #4a5568;
16
+ --accent-color: #63b3ed;
17
+ }
18
+
19
+ body {
20
+ background-color: #0f172a;
21
+ color: #e2e8f0;
22
+ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
23
+ }
24
+
25
+ .math-display {
26
+ font-size: 1.2rem;
27
+ text-align: center;
28
+ margin: 1.5rem 0;
29
+ }
30
+
31
+ .algorithm-card {
32
+ transition: transform 0.3s ease, box-shadow 0.3s ease;
33
+ border: 1px solid rgba(94, 94, 94, 0.3);
34
+ }
35
+
36
+ .algorithm-card:hover {
37
+ transform: translateY(-5px);
38
+ box-shadow: 0 10px 25px rgba(94, 94, 94, 0.4);
39
+ }
40
+
41
+ .nav-link {
42
+ position: relative;
43
+ }
44
+
45
+ .nav-link::after {
46
+ content: '';
47
+ position: absolute;
48
+ bottom: -5px;
49
+ left: 0;
50
+ width: 0;
51
+ height: 2px;
52
+ background-color: var(--accent-color);
53
+ transition: width 0.3s ease;
54
+ }
55
+
56
+ .nav-link:hover::after {
57
+ width: 100%;
58
+ }
59
+
60
+ .visualization-container {
61
+ background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
62
+ border-radius: 12px;
63
+ box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
64
+ }
65
+
66
+ .code-block {
67
+ background-color: #1e293b;
68
+ border-left: 4px solid var(--accent-color);
69
+ font-family: 'Fira Code', monospace;
70
+ }
71
+ </style>
72
+ </head>
73
+ <body class="min-h-screen">
74
+ <!-- Navigation -->
75
+ <nav class="bg-slate-900 border-b border-slate-700 sticky top-0 z-50">
76
+ <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
77
+ <div class="flex items-center justify-between h-16">
78
+ <div class="flex items-center">
79
+ <div class="flex-shrink-0 flex items-center">
80
+ <i data-feather="cpu" class="text-blue-400 mr-2"></i>
81
+ <span class="font-bold text-xl text-white">Algorithm Animator</span>
82
+ </div>
83
+ <div class="hidden md:block">
84
+ <div class="ml-10 flex items-baseline space-x-4">
85
+ <a href="#" class="nav-link text-white px-3 py-2 rounded-md text-sm font-medium">Home</a>
86
+ <a href="sorting.html" class="nav-link text-gray-300 hover:text-white px-3 py-2 rounded-md text-sm font-medium">Sorting</a>
87
+ <a href="graph.html" class="nav-link text-gray-300 hover:text-white px-3 py-2 rounded-md text-sm font-medium">Graph Algorithms</a>
88
+ <a href="dynamic.html" class="nav-link text-gray-300 hover:text-white px-3 py-2 rounded-md text-sm font-medium">Dynamic Programming</a>
89
+ </div>
90
+ </div>
91
+ </div>
92
+ <div class="hidden md:block">
93
+ <div class="ml-4 flex items-center md:ml-6">
94
+ <button class="bg-slate-800 p-1 rounded-full text-gray-400 hover:text-white focus:outline-none">
95
+ <i data-feather="search" class="h-5 w-5"></i>
96
+ </button>
97
+ </div>
98
+ </div>
99
+ </div>
100
+ </div>
101
+ </nav>
102
+
103
+ <!-- Hero Section -->
104
+ <div class="relative overflow-hidden">
105
+ <div class="max-w-7xl mx-auto">
106
+ <div class="relative z-10 pb-8 bg-transparent sm:pb-16 md:pb-20 lg:max-w-2xl lg:w-full lg:pb-28 xl:pb-32">
107
+ <main class="mt-10 mx-auto max-w-7xl px-4 sm:mt-12 sm:px-6 md:mt-16 lg:mt-20 lg:px-8 xl:mt-28">
108
+ <div class="sm:text-center lg:text-left">
109
+ <h1 class="text-4xl tracking-tight font-extrabold text-white sm:text-5xl md:text-6xl">
110
+ <span class="block">Visualize Algorithms</span>
111
+ <span class="block text-blue-400 mt-2">Like Never Before</span>
112
+ </h1>
113
+ <p class="mt-3 text-base text-gray-300 sm:mt-5 sm:text-lg sm:max-w-xl sm:mx-auto md:mt-5 md:text-xl lg:mx-0">
114
+ Break down complex algorithmic concepts into easy-to-understand animated explanations with detailed step-by-step visualizations.
115
+ </p>
116
+ <div class="mt-5 sm:mt-8 sm:flex sm:justify-center lg:justify-start">
117
+ <div class="rounded-md shadow">
118
+ <a href="#algorithms" class="w-full flex items-center justify-center px-8 py-3 border border-transparent text-base font-medium rounded-md text-slate-900 bg-blue-400 hover:bg-blue-500 md:py-4 md:text-lg md:px-10">
119
+ Get Started
120
+ </a>
121
+ </div>
122
+ <div class="mt-3 sm:mt-0 sm:ml-3">
123
+ <a href="#" class="w-full flex items-center justify-center px-8 py-3 border border-transparent text-base font-medium rounded-md text-blue-300 bg-slate-800 hover:bg-slate-700 md:py-4 md:text-lg md:px-10">
124
+ View Examples
125
+ </a>
126
+ </div>
127
+ </div>
128
+ </div>
129
+ </main>
130
+ </div>
131
+ </div>
132
+ <div class="lg:absolute lg:inset-y-0 lg:right-0 lg:w-1/2">
133
+ <div class="h-56 w-full bg-gradient-to-r from-blue-500 to-purple-600 sm:h-72 lg:w-full lg:h-full opacity-20"></div>
134
+ </div>
135
+ </div>
136
+
137
+ <!-- Algorithm Categories -->
138
+ <section id="algorithms" class="py-12 bg-slate-900">
139
+ <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
140
+ <div class="text-center">
141
+ <h2 class="text-3xl font-extrabold text-white sm:text-4xl">
142
+ Explore Algorithm Categories
143
+ </h2>
144
+ <p class="mt-3 max-w-2xl mx-auto text-xl text-gray-300 sm:mt-4">
145
+ Choose from various algorithm types to visualize and understand their inner workings
146
+ </p>
147
+ </div>
148
+
149
+ <div class="mt-10">
150
+ <div class="grid grid-cols-1 gap-8 sm:grid-cols-2 lg:grid-cols-3">
151
+ <!-- Sorting Algorithms -->
152
+ <div class="algorithm-card bg-slate-800 rounded-lg overflow-hidden shadow-lg">
153
+ <div class="p-6">
154
+ <div class="flex items-center">
155
+ <div class="flex-shrink-0 bg-blue-500 rounded-md p-3">
156
+ <i data-feather="bar-chart-2" class="h-6 w-6 text-white"></i>
157
+ </div>
158
+ <div class="ml-4">
159
+ <h3 class="text-lg font-medium text-white">Sorting Algorithms</h3>
160
+ <p class="mt-1 text-sm text-gray-300">Quick Sort, Merge Sort, Bubble Sort</p>
161
+ </div>
162
+ </div>
163
+ <div class="mt-6">
164
+ <a href="sorting.html" class="text-blue-400 hover:text-blue-300 font-medium">
165
+ Explore Visualizations
166
+ <i data-feather="arrow-right" class="inline ml-1 h-4 w-4"></i>
167
+ </a>
168
+ </div>
169
+ </div>
170
+ </div>
171
+
172
+ <!-- Graph Algorithms -->
173
+ <div class="algorithm-card bg-slate-800 rounded-lg overflow-hidden shadow-lg">
174
+ <div class="p-6">
175
+ <div class="flex items-center">
176
+ <div class="flex-shrink-0 bg-green-500 rounded-md p-3">
177
+ <i data-feather="git-branch" class="h-6 w-6 text-white"></i>
178
+ </div>
179
+ <div class="ml-4">
180
+ <h3 class="text-lg font-medium text-white">Graph Algorithms</h3>
181
+ <p class="mt-1 text-sm text-gray-300">Dijkstra, BFS, DFS, MST</p>
182
+ </div>
183
+ </div>
184
+ <div class="mt-6">
185
+ <a href="graph.html" class="text-green-400 hover:text-green-300 font-medium">
186
+ Explore Visualizations
187
+ <i data-feather="arrow-right" class="inline ml-1 h-4 w-4"></i>
188
+ </a>
189
+ </div>
190
+ </div>
191
+ </div>
192
+
193
+ <!-- Dynamic Programming -->
194
+ <div class="algorithm-card bg-slate-800 rounded-lg overflow-hidden shadow-lg">
195
+ <div class="p-6">
196
+ <div class="flex items-center">
197
+ <div class="flex-shrink-0 bg-purple-500 rounded-md p-3">
198
+ <i data-feather="layers" class="h-6 w-6 text-white"></i>
199
+ </div>
200
+ <div class="ml-4">
201
+ <h3 class="text-lg font-medium text-white">Dynamic Programming</h3>
202
+ <p class="mt-1 text-sm text-gray-300">Fibonacci, Knapsack, LCS</p>
203
+ </div>
204
+ </div>
205
+ <div class="mt-6">
206
+ <a href="dynamic.html" class="text-purple-400 hover:text-purple-300 font-medium">
207
+ Explore Visualizations
208
+ <i data-feather="arrow-right" class="inline ml-1 h-4 w-4"></i>
209
+ </a>
210
+ </div>
211
+ </div>
212
+ </div>
213
+ </div>
214
+ </div>
215
+ </div>
216
+ </section>
217
+
218
+ <!-- How It Works -->
219
+ <section class="py-12 bg-slate-800">
220
+ <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
221
+ <div class="lg:text-center">
222
+ <h2 class="text-base text-blue-400 font-semibold tracking-wide uppercase">How It Works</h2>
223
+ <p class="mt-2 text-3xl leading-8 font-extrabold tracking-tight text-white sm:text-4xl">
224
+ Understanding Algorithms Visually
225
+ </p>
226
+ <p class="mt-4 max-w-2xl text-xl text-gray-300 lg:mx-auto">
227
+ Our visualization tool breaks down complex algorithms into digestible steps with clear animations.
228
+ </p>
229
+ </div>
230
+
231
+ <div class="mt-10">
232
+ <div class="space-y-10 md:space-y-0 md:grid md:grid-cols-3 md:gap-x-8 md:gap-y-10">
233
+ <div class="flex">
234
+ <div class="flex-shrink-0">
235
+ <div class="flex items-center justify-center h-12 w-12 rounded-md bg-blue-500 text-white">
236
+ <i data-feather="play-circle" class="h-6 w-6"></i>
237
+ </div>
238
+ </div>
239
+ <div class="ml-4">
240
+ <h3 class="text-lg font-medium text-white">Step-by-Step Visualization</h3>
241
+ <p class="mt-2 text-base text-gray-300">
242
+ Each algorithm is broken down into discrete steps with visual representations of data structures and operations.
243
+ </p>
244
+ </div>
245
+ </div>
246
+
247
+ <div class="flex">
248
+ <div class="flex-shrink-0">
249
+ <div class="flex items-center justify-center h-12 w-12 rounded-md bg-green-500 text-white">
250
+ <i data-feather="book-open" class="h-6 w-6"></i>
251
+ </div>
252
+ </div>
253
+ <div class="ml-4">
254
+ <h3 class="text-lg font-medium text-white">Mathematical Explanation</h3>
255
+ <p class="mt-2 text-base text-gray-300">
256
+ Clear mathematical notation accompanies each visualization to explain the underlying principles.
257
+ </p>
258
+ </div>
259
+ </div>
260
+
261
+ <div class="flex">
262
+ <div class="flex-shrink-0">
263
+ <div class="flex items-center justify-center h-12 w-12 rounded-md bg-purple-500 text-white">
264
+ <i data-feather="code" class="h-6 w-6"></i>
265
+ </div>
266
+ </div>
267
+ <div class="ml-4">
268
+ <h3 class="text-lg font-medium text-white">Interactive Code</h3>
269
+ <p class="mt-2 text-base text-gray-300">
270
+ Follow along with pseudocode and real implementations that highlight key algorithmic concepts.
271
+ </p>
272
+ </div>
273
+ </div>
274
+ </div>
275
+ </div>
276
+ </div>
277
+ </section>
278
+
279
+ <!-- Sample Visualization Preview -->
280
+ <section class="py-12 bg-slate-900">
281
+ <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
282
+ <div class="text-center">
283
+ <h2 class="text-3xl font-extrabold text-white sm:text-4xl">
284
+ Sample Visualization Preview
285
+ </h2>
286
+ <p class="mt-3 max-w-2xl mx-auto text-xl text-gray-300 sm:mt-4">
287
+ See how our visualizations bring algorithms to life
288
+ </p>
289
+ </div>
290
+
291
+ <div class="mt-10 flex flex-col lg:flex-row gap-8">
292
+ <div class="lg:w-1/2">
293
+ <div class="visualization-container p-6 rounded-xl">
294
+ <h3 class="text-xl font-bold text-white mb-4">Merge Sort Visualization</h3>
295
+ <div class="bg-slate-800 rounded-lg p-4 h-64 flex items-center justify-center">
296
+ <div class="text-center">
297
+ <div class="flex justify-center space-x-2 mb-4">
298
+ <div class="w-8 h-16 bg-blue-500 rounded-t"></div>
299
+ <div class="w-8 h-12 bg-blue-400 rounded-t"></div>
300
+ <div class="w-8 h-20 bg-blue-500 rounded-t"></div>
301
+ <div class="w-8 h-8 bg-blue-400 rounded-t"></div>
302
+ <div class="w-8 h-16 bg-blue-500 rounded-t"></div>
303
+ <div class="w-8 h-12 bg-blue-400 rounded-t"></div>
304
+ </div>
305
+ <p class="text-gray-300">Array being divided and merged</p>
306
+ </div>
307
+ </div>
308
+ <div class="mt-4">
309
+ <div class="code-block p-4 rounded">
310
+ <pre class="text-green-400 text-sm">
311
+ function mergeSort(arr):
312
+ if length(arr) <= 1:
313
+ return arr
314
+
315
+ mid = length(arr) / 2
316
+ left = mergeSort(arr[0...mid])
317
+ right = mergeSort(arr[mid...end])
318
+
319
+ return merge(left, right)</pre>
320
+ </div>
321
+ </div>
322
+ </div>
323
+ </div>
324
+
325
+ <div class="lg:w-1/2">
326
+ <div class="visualization-container p-6 rounded-xl">
327
+ <h3 class="text-xl font-bold text-white mb-4">Mathematical Explanation</h3>
328
+ <div class="math-display text-blue-300">
329
+ \( T(n) = 2T\left(\frac{n}{2}\right) + O(n) \)
330
+ </div>
331
+ <div class="mt-4 text-gray-300">
332
+ <p class="mb-4">The recurrence relation for merge sort shows that the problem is divided into two subproblems of half the size, and then combined in linear time.</p>
333
+ <p>The solution to this recurrence is:</p>
334
+ <div class="math-display text-blue-300">
335
+ \( T(n) = O(n \log n) \)
336
+ </div>
337
+ <p class="mt-4">This makes merge sort one of the most efficient sorting algorithms with guaranteed \( O(n \log n) \) performance.</p>
338
+ </div>
339
+ </div>
340
+ </div>
341
+ </div>
342
+ </div>
343
+ </section>
344
+
345
+ <!-- Footer -->
346
+ <footer class="bg-slate-900 border-t border-slate-800">
347
+ <div class="max-w-7xl mx-auto py-12 px-4 sm:px-6 lg:px-8">
348
+ <div class="md:flex md:items-center md:justify-between">
349
+ <div class="flex justify-center md:justify-start">
350
+ <div class="flex items-center">
351
+ <i data-feather="cpu" class="text-blue-400 mr-2"></i>
352
+ <span class="text-white font-bold">Algorithm Animator</span>
353
+ </div>
354
+ </div>
355
+ <div class="mt-8 md:mt-0 md:order-1">
356
+ <p class="text-center text-base text-gray-400">
357
+ &copy; 2023 Algorithm Animator. All rights reserved.
358
+ </p>
359
+ </div>
360
+ </div>
361
+ </div>
362
+ </footer>
363
+
364
+ <script>
365
+ feather.replace();
366
+ </script>
367
+ </body>
368
  </html>
sorting.html ADDED
@@ -0,0 +1,251 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Sorting Algorithms - Algorithm Animator</title>
7
+ <link rel="icon" type="image/x-icon" href="/static/favicon.ico">
8
+ <script src="https://cdn.tailwindcss.com"></script>
9
+ <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
10
+ <script src="https://unpkg.com/feather-icons"></script>
11
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML" async></script>
12
+ <style>
13
+ body {
14
+ background-color: #0f172a;
15
+ color: #e2e8f0;
16
+ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
17
+ }
18
+
19
+ .algorithm-selector {
20
+ background-color: #1e293b;
21
+ border-radius: 8px;
22
+ transition: all 0.3s ease;
23
+ }
24
+
25
+ .algorithm-selector:hover {
26
+ background-color: #334155;
27
+ }
28
+
29
+ .active-algorithm {
30
+ background-color: #334155;
31
+ border-left: 4px solid #60a5fa;
32
+ }
33
+
34
+ .visualization-area {
35
+ background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
36
+ border-radius: 12px;
37
+ box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
38
+ }
39
+
40
+ .array-bar {
41
+ background: linear-gradient(to top, #3b82f6, #60a5fa);
42
+ border-radius: 4px 4px 0 0;
43
+ transition: height 0.3s ease, background-color 0.3s ease;
44
+ }
45
+
46
+ .comparing {
47
+ background: linear-gradient(to top, #f59e0b, #fbbf24);
48
+ }
49
+
50
+ .swapping {
51
+ background: linear-gradient(to top, #ef4444, #f87171);
52
+ }
53
+
54
+ .sorted {
55
+ background: linear-gradient(to top, #10b981, #34d399);
56
+ }
57
+
58
+ .code-block {
59
+ background-color: #1e293b;
60
+ border-left: 4px solid #60a5fa;
61
+ font-family: 'Fira Code', monospace;
62
+ }
63
+
64
+ .complexity-badge {
65
+ background-color: #334155;
66
+ }
67
+ </style>
68
+ </head>
69
+ <body class="min-h-screen">
70
+ <!-- Navigation -->
71
+ <nav class="bg-slate-900 border-b border-slate-700 sticky top-0 z-50">
72
+ <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
73
+ <div class="flex items-center justify-between h-16">
74
+ <div class="flex items-center">
75
+ <div class="flex-shrink-0 flex items-center">
76
+ <i data-feather="cpu" class="text-blue-400 mr-2"></i>
77
+ <span class="font-bold text-xl text-white">Algorithm Animator</span>
78
+ </div>
79
+ <div class="hidden md:block">
80
+ <div class="ml-10 flex items-baseline space-x-4">
81
+ <a href="index.html" class="text-gray-300 hover:text-white px-3 py-2 rounded-md text-sm font-medium">Home</a>
82
+ <a href="#" class="text-white px-3 py-2 rounded-md text-sm font-medium">Sorting</a>
83
+ <a href="graph.html" class="text-gray-300 hover:text-white px-3 py-2 rounded-md text-sm font-medium">Graph Algorithms</a>
84
+ <a href="dynamic.html" class="text-gray-300 hover:text-white px-3 py-2 rounded-md text-sm font-medium">Dynamic Programming</a>
85
+ </div>
86
+ </div>
87
+ </div>
88
+ </div>
89
+ </div>
90
+ </nav>
91
+
92
+ <!-- Main Content -->
93
+ <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
94
+ <div class="text-center mb-10">
95
+ <h1 class="text-3xl font-extrabold text-white sm:text-4xl">
96
+ Sorting Algorithms Visualization
97
+ </h1>
98
+ <p class="mt-3 max-w-2xl mx-auto text-xl text-gray-300">
99
+ Understand how different sorting algorithms work through interactive visualizations
100
+ </p>
101
+ </div>
102
+
103
+ <div class="flex flex-col lg:flex-row gap-8">
104
+ <!-- Algorithm Selection Panel -->
105
+ <div class="lg:w-1/4">
106
+ <div class="bg-slate-800 rounded-lg p-6 sticky top-24">
107
+ <h2 class="text-xl font-bold text-white mb-4">Sorting Algorithms</h2>
108
+ <div class="space-y-3">
109
+ <div class="algorithm-selector p-4 cursor-pointer active-algorithm">
110
+ <h3 class="font-medium text-white">Bubble Sort</h3>
111
+ <p class="text-sm text-gray-300 mt-1">Simple comparison-based algorithm</p>
112
+ </div>
113
+ <div class="algorithm-selector p-4 cursor-pointer">
114
+ <h3 class="font-medium text-white">Merge Sort</h3>
115
+ <p class="text-sm text-gray-300 mt-1">Divide and conquer approach</p>
116
+ </div>
117
+ <div class="algorithm-selector p-4 cursor-pointer">
118
+ <h3 class="font-medium text-white">Quick Sort</h3>
119
+ <p class="text-sm text-gray-300 mt-1">Efficient partitioning algorithm</p>
120
+ </div>
121
+ <div class="algorithm-selector p-4 cursor-pointer">
122
+ <h3 class="font-medium text-white">Heap Sort</h3>
123
+ <p class="text-sm text-gray-300 mt-1">Uses binary heap data structure</p>
124
+ </div>
125
+ <div class="algorithm-selector p-4 cursor-pointer">
126
+ <h3 class="font-medium text-white">Insertion Sort</h3>
127
+ <p class="text-sm text-gray-300 mt-1">Builds final sorted array one item at a time</p>
128
+ </div>
129
+ </div>
130
+
131
+ <div class="mt-8">
132
+ <h3 class="font-medium text-white mb-3">Controls</h3>
133
+ <div class="grid grid-cols-2 gap-3">
134
+ <button class="bg-blue-600 hover:bg-blue-700 text-white py-2 px-4 rounded">
135
+ Play
136
+ </button>
137
+ <button class="bg-slate-700 hover:bg-slate-600 text-white py-2 px-4 rounded">
138
+ Pause
139
+ </button>
140
+ <button class="bg-slate-700 hover:bg-slate-600 text-white py-2 px-4 rounded">
141
+ Reset
142
+ </button>
143
+ <button class="bg-slate-700 hover:bg-slate-600 text-white py-2 px-4 rounded">
144
+ Step
145
+ </button>
146
+ </div>
147
+ </div>
148
+
149
+ <div class="mt-8">
150
+ <h3 class="font-medium text-white mb-3">Array Size</h3>
151
+ <input type="range" min="5" max="50" value="15" class="w-full">
152
+ <div class="flex justify-between text-sm text-gray-400 mt-1">
153
+ <span>Small</span>
154
+ <span>Large</span>
155
+ </div>
156
+ </div>
157
+ </div>
158
+ </div>
159
+
160
+ <!-- Visualization Area -->
161
+ <div class="lg:w-3/4">
162
+ <div class="visualization-area p-6 rounded-xl">
163
+ <div class="flex justify-between items-center mb-6">
164
+ <h2 class="text-2xl font-bold text-white">Bubble Sort Visualization</h2>
165
+ <div class="flex space-x-3">
166
+ <div class="complexity-badge px-3 py-1 rounded-full text-sm">
167
+ Time: O(n²)
168
+ </div>
169
+ <div class="complexity-badge px-3 py-1 rounded-full text-sm">
170
+ Space: O(1)
171
+ </div>
172
+ </div>
173
+ </div>
174
+
175
+ <!-- Array Visualization -->
176
+ <div class="mb-8">
177
+ <div class="flex items-end justify-center h-64 space-x-1">
178
+ <!-- Bars representing array elements -->
179
+ <div class="array-bar w-8 h-32"></div>
180
+ <div class="array-bar w-8 h-24"></div>
181
+ <div class="array-bar w-8 h-40 comparing"></div>
182
+ <div class="array-bar w-8 h-28 swapping"></div>
183
+ <div class="array-bar w-8 h-36"></div>
184
+ <div class="array-bar w-8 h-20"></div>
185
+ <div class="array-bar w-8 h-44"></div>
186
+ <div class="array-bar w-8 h-32 sorted"></div>
187
+ <div class="array-bar w-8 h-24"></div>
188
+ <div class="array-bar w-8 h-36"></div>
189
+ </div>
190
+ </div>
191
+
192
+ <!-- Current Step Description -->
193
+ <div class="bg-slate-800 rounded-lg p-4 mb-6">
194
+ <h3 class="font-bold text-white mb-2">Current Step</h3>
195
+ <p class="text-gray-300">Comparing elements at positions 2 and 3. Since 40 > 28, we swap them.</p>
196
+ </div>
197
+
198
+ <!-- Pseudocode -->
199
+ <div class="code-block p-4 rounded mb-6">
200
+ <h3 class="font-bold text-white mb-2">Pseudocode</h3>
201
+ <pre class="text-green-400 text-sm">
202
+ for i = 0 to n-1:
203
+ for j = 0 to n-i-2:
204
+ if array[j] > array[j+1]:
205
+ swap(array[j], array[j+1])</pre>
206
+ </div>
207
+
208
+ <!-- Mathematical Explanation -->
209
+ <div class="bg-slate-800 rounded-lg p-4">
210
+ <h3 class="font-bold text-white mb-3">Mathematical Analysis</h3>
211
+ <div class="math-display text-blue-300">
212
+ \( \text{Worst Case: } O(n^2) \)
213
+ </div>
214
+ <p class="text-gray-300 mt-3">
215
+ In the worst case (reverse sorted array), bubble sort requires \( n-1 \) passes,
216
+ with the \( i^{th} \) pass making \( n-i \) comparisons. The total number of
217
+ comparisons is:
218
+ </p>
219
+ <div class="math-display text-blue-300">
220
+ \( \sum_{i=1}^{n-1}(n-i) = \frac{n(n-1)}{2} = O(n^2) \)
221
+ </div>
222
+ </div>
223
+ </div>
224
+ </div>
225
+ </div>
226
+ </div>
227
+
228
+ <!-- Footer -->
229
+ <footer class="bg-slate-900 border-t border-slate-800 mt-12">
230
+ <div class="max-w-7xl mx-auto py-12 px-4 sm:px-6 lg:px-8">
231
+ <div class="md:flex md:items-center md:justify-between">
232
+ <div class="flex justify-center md:justify-start">
233
+ <div class="flex items-center">
234
+ <i data-feather="cpu" class="text-blue-400 mr-2"></i>
235
+ <span class="text-white font-bold">Algorithm Animator</span>
236
+ </div>
237
+ </div>
238
+ <div class="mt-8 md:mt-0 md:order-1">
239
+ <p class="text-center text-base text-gray-400">
240
+ &copy; 2023 Algorithm Animator. All rights reserved.
241
+ </p>
242
+ </div>
243
+ </div>
244
+ </div>
245
+ </footer>
246
+
247
+ <script>
248
+ feather.replace();
249
+ </script>
250
+ </body>
251
+ </html>