aigpt4robo commited on
Commit
2340e29
·
verified ·
1 Parent(s): 334e047

undefined - Initial Deployment

Browse files
Files changed (2) hide show
  1. README.md +6 -4
  2. index.html +483 -19
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Awesomeinsertionsortvisulizer
3
- emoji: 👀
4
- colorFrom: indigo
5
  colorTo: blue
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: awesomeinsertionsortvisulizer
3
+ emoji: 🐳
4
+ colorFrom: pink
5
  colorTo: blue
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - deepsite
10
  ---
11
 
12
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
index.html CHANGED
@@ -1,19 +1,483 @@
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>Insertion Sort Visualizer</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
9
+ <script>
10
+ tailwind.config = {
11
+ theme: {
12
+ extend: {
13
+ colors: {
14
+ primary: '#3B82F6',
15
+ secondary: '#10B981',
16
+ highlight: '#F59E0B',
17
+ sorted: '#10B981',
18
+ comparing: '#FBBF24',
19
+ current: '#EF4444',
20
+ info: '#60A5FA'
21
+ }
22
+ }
23
+ }
24
+ }
25
+ </script>
26
+ <style>
27
+ .array-bar {
28
+ transition: all 0.3s ease;
29
+ }
30
+ .algorithm-step {
31
+ transition: background-color 0.3s ease;
32
+ }
33
+ .card-hover {
34
+ transition: transform 0.3s ease, box-shadow 0.3s ease;
35
+ }
36
+ .card-hover:hover {
37
+ transform: translateY(-5px);
38
+ box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
39
+ }
40
+ </style>
41
+ </head>
42
+ <body class="bg-gray-50 font-sans">
43
+ <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
44
+ <!-- Header -->
45
+ <header class="text-center mb-12">
46
+ <h1 class="text-4xl font-bold text-gray-900 mb-2">Insertion Sort Visualizer</h1>
47
+ <p class="text-gray-600 max-w-3xl mx-auto">
48
+ Understand insertion sort algorithm through step-by-step visualization and detailed explanation
49
+ </p>
50
+ </header>
51
+
52
+ <div class="grid grid-cols-1 lg:grid-cols-3 gap-8">
53
+ <!-- Algorithm Explanation -->
54
+ <div class="lg:col-span-2 space-y-8">
55
+ <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover">
56
+ <div class="p-6 border-b border-gray-200 bg-gradient-to-r from-primary to-blue-400">
57
+ <h2 class="text-2xl font-bold text-white">Understanding Insertion Sort</h2>
58
+ </div>
59
+ <div class="p-6">
60
+ <div class="flex items-start mb-6">
61
+ <div class="bg-blue-100 p-4 rounded-full mr-4">
62
+ <i class="fas fa-lightbulb text-blue-600 text-xl"></i>
63
+ </div>
64
+ <div>
65
+ <h3 class="text-lg font-semibold text-gray-800 mb-2">What is Insertion Sort?</h3>
66
+ <p class="text-gray-600">
67
+ Insertion sort is a simple, efficient sorting algorithm that builds the final sorted array one element at a time.
68
+ It works similarly to how you might sort a hand of playing cards by repeatedly inserting a new card into
69
+ its correct position in your already sorted hand.
70
+ </p>
71
+ </div>
72
+ </div>
73
+
74
+ <div class="bg-blue-50 rounded-lg p-5 mb-6">
75
+ <h3 class="font-bold text-gray-800 flex items-center mb-3">
76
+ <i class="fas fa-code mr-2 text-blue-600"></i> Algorithmic Steps
77
+ </h3>
78
+ <ul class="space-y-3">
79
+ <li class="flex items-start">
80
+ <span class="bg-blue-500 text-white rounded-full h-6 w-6 flex items-center justify-center mr-3 flex-shrink-0">1</span>
81
+ <span class="text-gray-700">Start with the second element (index 1) and consider it as the key</span>
82
+ </li>
83
+ <li class="flex items-start">
84
+ <span class="bg-blue-500 text-white rounded-full h-6 w-6 flex items-center justify-center mr-3 flex-shrink-0">2</span>
85
+ <span class="text-gray-700">Compare key with elements to its left</span>
86
+ </li>
87
+ <li class="flex items-start">
88
+ <span class="bg-blue-500 text-white rounded-full h-6 w-6 flex items-center justify-center mr-3 flex-shrink-0">3</span>
89
+ <span class="text-gray-700">If key is smaller, shift elements to the right</span>
90
+ </li>
91
+ <li class="flex items-start">
92
+ <span class="bg-blue-500 text-white rounded-full h-6 w-6 flex items-center justify-center mr-3 flex-shrink-0">4</span>
93
+ <span class="text-gray-700">Insert key in its correct sorted position</span>
94
+ </li>
95
+ <li class="flex items-start">
96
+ <span class="bg-blue-500 text-white rounded-full h-6 w-6 flex items-center justify-center mr-3 flex-shrink-0">5</span>
97
+ <span class="text-gray-700">Repeat for all elements in the array</span>
98
+ </li>
99
+ </ul>
100
+ </div>
101
+
102
+ <div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-6">
103
+ <div class="bg-emerald-50 rounded-lg p-5">
104
+ <h3 class="font-bold text-gray-800 flex items-center mb-3">
105
+ <i class="fas fa-check-circle mr-2 text-emerald-600"></i> Advantages
106
+ </h3>
107
+ <ul class="space-y-2 text-gray-700">
108
+ <li class="flex items-start">
109
+ <i class="fas fa-chevron-right text-emerald-500 mt-1 mr-2 text-xs"></i>
110
+ <span>Efficient for small data sets</span>
111
+ </li>
112
+ <li class="flex items-start">
113
+ <i class="fas fa-chevron-right text-emerald-500 mt-1 mr-2 text-xs"></i>
114
+ <span>Adaptive - efficient for nearly sorted data</span>
115
+ </li>
116
+ <li class="flex items-start">
117
+ <i class="fas fa-chevron-right text-emerald-500 mt-1 mr-2 text-xs"></i>
118
+ <span>Stable sorting algorithm</span>
119
+ </li>
120
+ <li class="flex items-start">
121
+ <i class="fas fa-chevron-right text-emerald-500 mt-1 mr-2 text-xs"></i>
122
+ <span>Low overhead - only O(1) additional memory</span>
123
+ </li>
124
+ </ul>
125
+ </div>
126
+
127
+ <div class="bg-amber-50 rounded-lg p-5">
128
+ <h3 class="font-bold text-gray-800 flex items-center mb-3">
129
+ <i class="fas fa-exclamation-triangle mr-2 text-amber-600"></i> Limitations
130
+ </h3>
131
+ <ul class="space-y-2 text-gray-700">
132
+ <li class="flex items-start">
133
+ <i class="fas fa-chevron-right text-amber-500 mt-1 mr-2 text-xs"></i>
134
+ <span>Inefficient for large lists (O(n²) worst-case)</span>
135
+ </li>
136
+ <li class="flex items-start">
137
+ <i class="fas fa-chevron-right text-amber-500 mt-1 mr-2 text-xs"></i>
138
+ <span>Performance degrades with large unsorted data</span>
139
+ </li>
140
+ <li class="flex items-start">
141
+ <i class="fas fa-chevron-right text-amber-500 mt-1 mr-2 text-xs"></i>
142
+ <span>Less efficient than algorithms like quicksort for larger datasets</span>
143
+ </li>
144
+ </ul>
145
+ </div>
146
+ </div>
147
+ </div>
148
+ </div>
149
+
150
+ <!-- Algorithm Demonstration Steps -->
151
+ <div class="bg-white rounded-xl shadow-md overflow-hidden card-hover">
152
+ <div class="p-6 border-b border-gray-200 bg-gradient-to-r from-secondary to-emerald-400">
153
+ <h2 class="text-2xl font-bold text-white">Step-by-Step Process</h2>
154
+ </div>
155
+ <div class="p-6">
156
+ <div id="stepContainer" class="space-y-4">
157
+ <div class="algorithm-step bg-white border border-gray-200 rounded-lg p-4">
158
+ <div class="flex items-center mb-2">
159
+ <div class="bg-green-500 text-white rounded-full h-8 w-8 flex items-center justify-center mr-3 flex-shrink-0">1</div>
160
+ <h3 class="font-bold text-gray-800">Start with the second element</h3>
161
+ </div>
162
+ <p class="text-gray-600 ml-11 mb-3">
163
+ Consider array[1] as the key (current element to be sorted)
164
+ </p>
165
+ <div class="flex justify-center">
166
+ <div class="flex items-end h-32">
167
+ <div class="array-bar flex flex-col items-center mx-1 w-12 bg-blue-500" style="height: 80px;">
168
+ <span class="text-white font-bold mt-1">8</span>
169
+ <span class="text-white text-xs">[0]</span>
170
+ </div>
171
+ <div class="array-bar flex flex-col items-center mx-1 w-12 bg-red-500" style="height: 50px;">
172
+ <span class="text-white font-bold mt-1">5</span>
173
+ <span class="text-white text-xs">[1]</span>
174
+ <span class="text-white text-xs mt-1">(Key)</span>
175
+ </div>
176
+ <div class="array-bar flex flex-col items-center mx-1 w-12 bg-gray-400" style="height: 70px;">
177
+ <span class="text-white font-bold mt-1">7</span>
178
+ <span class="text-white text-xs">[2]</span>
179
+ </div>
180
+ <div class="array-bar flex flex-col items-center mx-1 w-12 bg-gray-400" style="height: 40px;">
181
+ <span class="text-white font-bold mt-1">3</span>
182
+ <span class="text-white text-xs">[3]</span>
183
+ </div>
184
+ </div>
185
+ </div>
186
+ </div>
187
+
188
+ <div class="algorithm-step bg-white border border-gray-200 rounded-lg p-4">
189
+ <div class="flex items-center mb-2">
190
+ <div class="bg-green-500 text-white rounded-full h-8 w-8 flex items-center justify-center mr-3 flex-shrink-0">2</div>
191
+ <h3 class="font-bold text-gray-800">Compare with left element</h3>
192
+ </div>
193
+ <p class="text-gray-600 ml-11 mb-3">
194
+ Compare key (5) with element to its left (8). Since 5 < 8, we need to shift 8 to the right.
195
+ </p>
196
+ <div class="flex justify-center">
197
+ <div class="flex items-end h-32">
198
+ <div class="array-bar flex flex-col items-center mx-1 w-12 bg-yellow-500" style="height: 80px;">
199
+ <span class="text-white font-bold mt-1">8</span>
200
+ <span class="text-white text-xs">[0]</span>
201
+ <span class="text-white text-xs mt-1">Comparing</span>
202
+ </div>
203
+ <div class="array-bar flex flex-col items-center mx-1 w-12 bg-red-500" style="height: 50px;">
204
+ <span class="text-white font-bold mt-1">5</span>
205
+ <span class="text-white text-xs">[1]</span>
206
+ <span class="text-white text-xs mt-1">(Key)</span>
207
+ </div>
208
+ <div class="array-bar flex flex-col items-center mx-1 w-12 bg-gray-400" style="height: 70px;">
209
+ <span class="text-white font-bold mt-1">7</span>
210
+ <span class="text-white text-xs">[2]</span>
211
+ </div>
212
+ <div class="array-bar flex flex-col items-center mx-1 w-12 bg-gray-400" style="height: 40px;">
213
+ <span class="text-white font-bold mt-1">3</span>
214
+ <span class="text-white text-xs">[3]</span>
215
+ </div>
216
+ </div>
217
+ </div>
218
+ </div>
219
+
220
+ <div class="algorithm-step bg-white border border-gray-200 rounded-lg p-4">
221
+ <div class="flex items-center mb-2">
222
+ <div class="bg-green-500 text-white rounded-full h-8 w-8 flex items-center justify-center mr-3 flex-shrink-0">3</div>
223
+ <h3 class="font-bold text-gray-800">Shift and Insert</h3>
224
+ </div>
225
+ <p class="text-gray-600 ml-11 mb-3">
226
+ Shift 8 to the right and insert key (5) in its correct position.
227
+ </p>
228
+ <div class="flex justify-center">
229
+ <div class="flex items-end h-32">
230
+ <div class="array-bar flex flex-col items-center mx-1 w-12 bg-green-500" style="height: 50px;">
231
+ <span class="text-white font-bold mt-1">5</span>
232
+ <span class="text-white text-xs">[0]</span>
233
+ <span class="text-white text-xs mt-1">Sorted</span>
234
+ </div>
235
+ <div class="array-bar flex flex-col items-center mx-1 w-12 bg-green-500" style="height: 80px;">
236
+ <span class="text-white font-bold mt-1">8</span>
237
+ <span class="text-white text-xs">[1]</span>
238
+ <span class="text-white text-xs mt-1">Sorted</span>
239
+ </div>
240
+ <div class="array-bar flex flex-col items-center mx-1 w-12 bg-gray-400" style="height: 70px;">
241
+ <span class="text-white font-bold mt-1">7</span>
242
+ <span class="text-white text-xs">[2]</span>
243
+ </div>
244
+ <div class="array-bar flex flex-col items-center mx-1 w-12 bg-gray-400" style="height: 40px;">
245
+ <span class="text-white font-bold mt-1">3</span>
246
+ <span class="text-white text-xs">[3]</span>
247
+ </div>
248
+ </div>
249
+ </div>
250
+ </div>
251
+ </div>
252
+
253
+ <div class="mt-8 bg-blue-50 rounded-lg p-5">
254
+ <h3 class="font-bold text-gray-800 flex items-center mb-3">
255
+ <i class="fas fa-calculator mr-2 text-blue-600"></i> Complexity Analysis
256
+ </h3>
257
+ <div class="grid grid-cols-1 md:grid-cols-3 gap-4">
258
+ <div class="text-center p-4 bg-white rounded-lg">
259
+ <div class="text-lg font-semibold">Best Case</div>
260
+ <div class="text-2xl font-bold text-green-600">O(n)</div>
261
+ <p class="text-gray-600 mt-2">When array is already sorted</p>
262
+ </div>
263
+ <div class="text-center p-4 bg-white rounded-lg">
264
+ <div class="text-lg font-semibold">Average Case</div>
265
+ <div class="text-2xl font-bold text-amber-600">O(n²)</div>
266
+ <p class="text-gray-600 mt-2">Typical performance</p>
267
+ </div>
268
+ <div class="text-center p-4 bg-white rounded-lg">
269
+ <div class="text-lg font-semibold">Worst Case</div>
270
+ <div class="text-2xl font-bold text-red-600">O(n²)</div>
271
+ <p class="text-gray-600 mt-2">Reverse sorted array</p>
272
+ </div>
273
+ </div>
274
+ </div>
275
+ </div>
276
+ </div>
277
+ </div>
278
+
279
+ <!-- Visualization Panel -->
280
+ <div>
281
+ <div class="bg-white rounded-xl shadow-md overflow-hidden sticky top-8 card-hover">
282
+ <div class="p-6 border-b border-gray-200 bg-gradient-to-r from-highlight to-amber-400">
283
+ <h2 class="text-2xl font-bold text-white">Interactive Visualization</h2>
284
+ </div>
285
+ <div class="p-6">
286
+ <div id="visualization" class="mb-6">
287
+ <div class="flex flex-col items-center justify-center">
288
+ <!-- Key Display -->
289
+ <div id="key-display" class="mb-6 bg-amber-100 rounded-lg p-4 text-center">
290
+ <span class="text-gray-600 font-semibold">Current Key:</span>
291
+ <span id="current-key" class="ml-2 bg-red-500 text-white font-bold px-3 py-1 rounded-lg">5</span>
292
+ </div>
293
+
294
+ <!-- Array Visualization -->
295
+ <div class="h-64 w-full flex items-end justify-center px-4" id="array-container">
296
+ <div class="flex items-end">
297
+ <div class="array-bar flex flex-col items-center mx-1 w-12 bg-green-500" style="height: 80px;">
298
+ <span class="text-white font-bold mt-1">5</span>
299
+ <span class="text-white text-xs">[0]</span>
300
+ <span class="text-white text-xs mt-1">Sorted</span>
301
+ </div>
302
+ <div class="array-bar flex flex-col items-center mx-1 w-12 bg-green-500" style="height: 50px;">
303
+ <span class="text-white font-bold mt-1">8</span>
304
+ <span class="text-white text-xs">[1]</span>
305
+ <span class="text-white text-xs mt-1">Sorted</span>
306
+ </div>
307
+ <div class="array-bar flex flex-col items-center mx-1 w-12 bg-red-500" style="height: 70px;">
308
+ <span class="text-white font-bold mt-1">7</span>
309
+ <span class="text-white text-xs">[2]</span>
310
+ <span class="text-white text-xs mt-1">(Key)</span>
311
+ </div>
312
+ <div class="array-bar flex flex-col items-center mx-1 w-12 bg-gray-400" style="height: 40px;">
313
+ <span class="text-white font-bold mt-1">3</span>
314
+ <span class="text-white text-xs">[3]</span>
315
+ </div>
316
+ <div class="array-bar flex flex-col items-center mx-1 w-12 bg-gray-400" style="height: 100px;">
317
+ <span class="text-white font-bold mt-1">10</span>
318
+ <span class="text-white text-xs">[4]</span>
319
+ </div>
320
+ <div class="array-bar flex flex-col items-center mx-1 w-12 bg-gray-400" style="height: 60px;">
321
+ <span class="text-white font-bold mt-1">6</span>
322
+ <span class="text-white text-xs">[5]</span>
323
+ </div>
324
+ </div>
325
+ </div>
326
+
327
+ <!-- Status Information -->
328
+ <div id="status-info" class="mt-4 text-center px-4 py-3 bg-blue-100 rounded-lg w-full max-w-md">
329
+ <p class="font-medium text-blue-800">Comparing 7 and 8. Shift required.</p>
330
+ </div>
331
+ </div>
332
+ </div>
333
+
334
+ <!-- Controls -->
335
+ <div class="mt-6">
336
+ <div class="flex flex-wrap justify-center gap-3">
337
+ <button class="px-4 py-2 bg-blue-500 hover:bg-blue-600 text-white rounded-lg flex items-center">
338
+ <i class="fas fa-play mr-2"></i> Start
339
+ </button>
340
+ <button class="px-4 py-2 bg-yellow-500 hover:bg-yellow-600 text-white rounded-lg flex items-center">
341
+ <i class="fas fa-step-forward mr-2"></i> Next Step
342
+ </button>
343
+ <button class="px-4 py-2 bg-green-500 hover:bg-green-600 text-white rounded-lg flex items-center">
344
+ <i class="fas fa-random mr-2"></i> New Array
345
+ </button>
346
+ <button class="px-4 py-2 bg-purple-500 hover:bg-purple-600 text-white rounded-lg flex items-center">
347
+ <i class="fas fa-backward mr-2"></i> Reset
348
+ </button>
349
+ </div>
350
+
351
+ <div class="mt-6 bg-gray-100 rounded-lg p-4">
352
+ <h4 class="font-bold text-gray-800 mb-2 flex items-center">
353
+ <i class="fas fa-tachometer-alt mr-2 text-gray-600"></i> Adjust Speed
354
+ </h4>
355
+ <input type="range" min="1" max="10" value="5" class="w-full h-2 bg-gray-300 rounded-lg appearance-none cursor-pointer">
356
+ <div class="flex justify-between mt-1 text-sm text-gray-600">
357
+ <span>Slow</span>
358
+ <span>Medium</span>
359
+ <span>Fast</span>
360
+ </div>
361
+ </div>
362
+ </div>
363
+
364
+ <div class="mt-8 bg-gray-50 rounded-lg p-5">
365
+ <h3 class="font-bold text-gray-800 mb-3 flex items-center">
366
+ <i class="fas fa-lightbulb mr-2 text-yellow-500"></i> Key Insight
367
+ </h3>
368
+ <p class="text-gray-600">
369
+ Insertion sort's efficiency comes from its simplicity and adaptability.
370
+ While not optimal for large datasets, it excels when the data is nearly sorted
371
+ or when processing small datasets with low overhead.
372
+ </p>
373
+ <div class="mt-4 flex items-center">
374
+ <i class="fas fa-code mr-2 text-gray-500"></i>
375
+ <span class="text-sm bg-gray-200 px-2 py-1 rounded font-mono">arr[j + 1] = arr[j] // Shift element right</span>
376
+ </div>
377
+ </div>
378
+ </div>
379
+ </div>
380
+
381
+ <!-- Real-world Applications -->
382
+ <div class="mt-8 bg-white rounded-xl shadow-md overflow-hidden card-hover">
383
+ <div class="p-6 border-b border-gray-200 bg-gradient-to-r from-purple-500 to-indigo-400">
384
+ <h2 class="text-2xl font-bold text-white">Real-world Applications</h2>
385
+ </div>
386
+ <div class="p-6">
387
+ <ul class="space-y-4">
388
+ <li class="flex items-start">
389
+ <div class="bg-indigo-100 p-3 rounded-full mr-4">
390
+ <i class="fas fa-gamepad text-indigo-600"></i>
391
+ </div>
392
+ <div>
393
+ <h3 class="font-bold text-gray-800">Game Leaderboards</h3>
394
+ <p class="text-gray-600">Online games use insertion sort for player rankings where scores are constantly updated incrementally.</p>
395
+ </div>
396
+ </li>
397
+ <li class="flex items-start">
398
+ <div class="bg-indigo-100 p-3 rounded-full mr-4">
399
+ <i class="fas fa-database text-indigo-600"></i>
400
+ </div>
401
+ <div>
402
+ <h3 class="font-bold text-gray-800">Database Optimizations</h3>
403
+ <p class="text-gray-600">Databases use insertion sort for small datasets or when data is almost sorted.</p>
404
+ </div>
405
+ </li>
406
+ <li class="flex items-start">
407
+ <div class="bg-indigo-100 p-3 rounded-full mr-4">
408
+ <i class="fas fa-shopping-cart text-indigo-600"></i>
409
+ </div>
410
+ <div>
411
+ <h3 class="font-bold text-gray-800">E-commerce Filtering</h3>
412
+ <p class="text-gray-600">E-commerce sites use it for real-time sorting of products when filters change incrementally.</p>
413
+ </div>
414
+ </li>
415
+ <li class="flex items-start">
416
+ <div class="bg-indigo-100 p-3 rounded-full mr-4">
417
+ <i class="fas fa-network-wired text-indigo-600"></i>
418
+ </div>
419
+ <div>
420
+ <h3 class="font-bold text-gray-800">Network Routing</h3>
421
+ <p class="text-gray-600">Network devices sort routing tables efficiently when there are minor changes.</p>
422
+ </div>
423
+ </li>
424
+ </ul>
425
+ </div>
426
+ </div>
427
+ </div>
428
+ </div>
429
+
430
+ <!-- Footer -->
431
+ <footer class="mt-12 pt-6 border-t border-gray-200 text-center text-gray-600">
432
+ <p>Interactive Insertion Sort Visualizer & Algorithm Explanation</p>
433
+ <p class="mt-2">Explore how insertion sort efficiently builds a sorted array one element at a time.</p>
434
+ </footer>
435
+ </div>
436
+
437
+ <script>
438
+ // Sample array for the visualization
439
+ const sampleArray = [8, 5, 7, 3, 10, 6];
440
+
441
+ // State for the visualization
442
+ const state = {
443
+ array: [...sampleArray],
444
+ currentKeyIndex: 2, // Index of the current key element
445
+ comparingIndex: 1, // Index being compared with the key
446
+ isPlaying: false,
447
+ speed: 5,
448
+ sortedIndices: [0, 1]
449
+ };
450
+
451
+ // Initialize the visualization (would be enhanced in a complete implementation)
452
+ function initVisualization() {
453
+ // In a full implementation, this would handle rendering the array
454
+ // based on the current state, and updating the UI accordingly
455
+ console.log("Visualization initialized");
456
+ }
457
+
458
+ // Event listeners for buttons (simplified for this example)
459
+ document.addEventListener('DOMContentLoaded', function() {
460
+ initVisualization();
461
+
462
+ document.querySelectorAll('button').forEach(button => {
463
+ button.addEventListener('click', function() {
464
+ this.classList.add('animate-pulse');
465
+ setTimeout(() => {
466
+ this.classList.remove('animate-pulse');
467
+ }, 300);
468
+ });
469
+ });
470
+
471
+ // For the algorithm explanation steps
472
+ document.querySelectorAll('.algorithm-step').forEach(step => {
473
+ step.addEventListener('click', function() {
474
+ document.querySelectorAll('.algorithm-step').forEach(s => {
475
+ s.classList.remove('border-blue-500', 'bg-blue-50');
476
+ });
477
+ this.classList.add('border-blue-500', 'bg-blue-50');
478
+ });
479
+ });
480
+ });
481
+ </script>
482
+ <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=aigpt4robo/awesomeinsertionsortvisulizer" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
483
+ </html>