-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqueue-visualRepresentation.html
466 lines (342 loc) · 18.4 KB
/
queue-visualRepresentation.html
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DSA Visualizer - Queue</title>
<link rel="shortcut icon" href="images/icon1.jpeg" type="image/x-icon">
<script src="https://kit.fontawesome.com/176e14c7a2.js" crossorigin="anonymous"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<link rel="stylesheet" href="css/style.css">
</head>
<body onload="loadArrayPage()">
<nav class="navbar navbar-expand-lg">
<div class="container-fluid">
<a style="color: white; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; font-weight: 500; position: relative; top: -1px;"
class="navbar-brand" href="#">DSA Visualizer</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNavDropdown"
aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
<i style="color: white;" class="fa-solid fa-bars"></i>
</button>
<div class="collapse navbar-collapse justify-content-start mt-2" id="navbarNavDropdown">
<ul class="navbar-nav">
<li class="nav-item a" onclick="getIndex()">
<a class="nav-link">Data Structures</a>
<div class="underline "></div>
</li>
<li class="nav-item a" onclick="getCompiler()">
<a class="nav-link">Compiler</a>
<div class="underline"></div>
</li>
<li class="nav-item a" onclick="getTopic()">
<a class="nav-link">DSA Topics</a>
<div class="underline"></div>
</li>
</ul>
</div>
<script>
function getIndex() {
window.location.href = 'https://dsabrototype.vercel.app'
}
function getCompiler() {
window.location.href = 'https://dsabrototype.vercel.app/compiler.html'
}
function getTopic() {
window.location.href = 'https://dsabrototype.vercel.app/topics.html'
}
</script>
<div class="collapse navbar-collapse justify-content-end mt-2" id="navbarNavDropdown">
<ul class="navbar-nav">
<li class="nav-item a">
<a class="nav-link" id="stack_with_array_btn">Queue with Array</a>
<div class="underline"></div>
</li>
<li class="nav-item a">
<a class="nav-link" id="stack_with_ll_btn">Queue with Linked List</a>
<div class="underline"></div>
</li>
<li class="nav-item a">
<a class="nav-link" id="stack_with_queue_btn">Queue with Stack</a>
<div class="underline"></div>
</li>
</ul>
</div>
</div>
</nav>
<section id="message">
<h4 style="text-align: center;">Please make the window wider for a better user experience</h4>
</section>
<!-- stack with array part -->
<section id="content">
<section style="display: none;" id="stack_with_array">
<h1
style="font-family:'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; text-align: center; font-size: 22px; background-color: rgb(229, 229, 229); padding: 12px; padding-bottom: 16px; font-weight: 500;">
Queue with Array - <span style="color: chocolate;">Visual</span> Representation</h1>
<section style="display: flex; justify-content: space-around;" class="">
<section
style="display: flex; flex-direction: column; align-items: center; padding-top: 60px; width:600px; position: relative; left: 100px;">
<div class="array_area">
<div id="array_box" class="array_body">
<div id="0" class="index">
10
</div>
<div id="1" class="index">
10
</div>
<!-- <div id="2" class="index">
10
</div> -->
<!-- <div id="3" class="index">
10
</div> -->
</div>
</div>
<div class="array_area">
<div id="array_index" class="array_body1">
<div id="box0" class="ind">
0
</div>
<div id="box1" class="ind">
1
</div>
<!-- <div id="box2" class="ind">
2
</div> -->
<!-- <div id="box3" class="ind">
3
</div> -->
</div>
</div>
</section>
<section
style="display: flex; flex-direction: column; align-items: center; padding-top: 0px; position: relative;left: -300px;">
<div style="position: relative;" class="array_area">
<p style="text-align: center; position: relative; top: 20px;"><i id="out" style="font-size: 23px;"
class="fa-solid fa-arrow-up"></i></p>
<p style="text-align: center; position: relative; top: 5px;">Front</p>
<div style="display: flex; flex-direction: column;" id="stack_box" class="stack_body">
<div id="stack0" class="stack">
10
</div>
<div id="stack1" class="stack">
10
</div>
<!-- <div id="stack2" class="stack">
10
</div> -->
<!-- <div id="3" class="stack">
10
</div> -->
</div>
<p style="text-align: center; position: relative; top: 10px">Rare</p>
<p style="text-align: center; position: relative; top: 2px;"><i id="in" style="font-size: 23px;"
class="fa-solid fa-arrow-up"></i></p>
<!-- <p style="text-align: center; position: absolute; top: 120px; left: 100px;">Queue</p> -->
</div>
</section>
</section>
<section style="display: flex; justify-content: space-between; padding-left: 20px;" id="form_section">
<!-- basic operations -->
<div id="stack_with_array_div" style="display: flex; flex-direction: column;">
<p
style="font-family:'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; font-weight: 500; font-size: 20px; padding-left: 20px;">
Basic Operations</p>
<div
style="padding: 30px; overflow-y: auto; padding: 20px; padding-top: 10px; background-color:rgba(99, 99, 99, 0); border-width: 2px; border-style: none; border-color: lightgray;">
<div class="">
<form action="" onsubmit="insertAtLast(event)">
v = <input type="number" id="insertedValue" required>
<input id="insertAtLastBtn" type="submit" value="Enqueue">
</form>
</div>
<br>
<div class="">
<form action="" onsubmit="removeValue(event)">
<input style="visibility: hidden;" type="number" id="number">
<input style="position: relative;left: 27px;" id="removeBtn" type="submit" value="Dequeue">
</form>
</div>
<br>
<div class="">
<form action="" onsubmit="findPeek(event)">
<input type="text" style="visibility: hidden;">
<input style="position: relative;left: 26px;" id="peek" type="submit" value="Peek">
</form>
</div>
</div>
</div>
<div id="note_pad_div" style="display: none; flex-direction: column; padding-right: 30px;">
<p
style="font-family:'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; font-weight: 500; font-size: 20px; padding-left: 0px;">
Explanation</p>
<div id="note_pad"
style="width:400px; background-color: rgb(229, 229, 229); padding: 20px; padding-top: 20px;">
</div>
</div>
</section>
</section>
<!-- queue with linked list -->
<section id="stack_with_ll" style="display: none;">
<h1
style="font-family:'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; text-align: center; font-size: 22px; background-color: rgb(229, 229, 229); padding: 12px; padding-bottom: 16px; font-weight: 500;">
Queue with LinkedList - <span style="color: chocolate;">Visual</span> Representation</h1>
<div class="container" style="display: flex;flex-direction: column; justify-content: center; height: 60vh; width: 100%;">
<li style="font-size: 15px; font-weight: 500;">Enqueue operation involves adding a value to the queue, which corresponds to appending a new node to the linked list. This means inserting the new value at the end of the list.</li>
<br>
<li style="font-size: 15px; font-weight: 500;">Dequeue operation involves removing a value from the queue, which corresponds to removing the head node from the linked list. The next node becomes the new head of the list.</li>
<br>
<a style="text-align: center; font-size: 15px; font-weight: 500;" href="linkedList-visualRepresention.html">For these operations, refer to the LinkedList Visual Representation.</a>
</div>
</section>
<!-- stack with queue part -->
<section style="display: none;" id="stack_with_queue">
<h1
style="font-family:'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; text-align: center; font-size: 22px; background-color: rgb(229, 229, 229); padding: 12px; padding-bottom: 16px; font-weight: 500;">
Queue with Stack - <span style="color: chocolate;">Visual</span> Representation</h1>
<section style="display: flex; justify-content: space-around; position: relative;" class="">
<section
style="display: flex; flex-direction: column; align-items: center; padding-top: 18px; padding-bottom: 42px; width:600px; position: relative; left: 100px;">
<div class="array_area">
<p>Stack 1</p>
<div id="array_box_queue" class="array_body">
<div id="array_stack_0" class="with_queue_index">
10
</div>
<div id="array_stack_1" class="with_queue_index">
10
</div>
</div>
</div>
<div class="array_area">
<div id="array_index_queue" class="array_index_body_with_queue">
<div id="stackbox0" class="with_queue_ind">
0
</div>
<div id="stackbox1" class="with_queue_ind">
1
</div>
</div>
</div>
<div id="queue2" style="display: none; position: absolute; top: 200px;">
<p>Stack 2</p>
<div style="visibility: hidden;" id="array_box_queue1" class="array_body">
</div>
<div class="array_area">
<div style="visibility: hidden;" id="array_index_queue1" class="array_index_body_with_queue1">
<div id="stackbox10" class="with_queue_ind1">
0
</div>
</div>
</div>
</div>
</section>
<section
style="display: flex; flex-direction: column; align-items: center; padding-top: 0px; position: relative;left: -300px;">
<div class="array_area">
<p style="text-align: center; position: relative; top: 20px;"><i id="out_with_queue"
style="font-size: 23px;" class="fa-solid fa-arrow-up"></i></p>
<p style="text-align: center; position: relative; top: 5px;">Front</p>
<div style="display: flex; flex-direction: column;" id="stack_box_queue" class="stack_body">
<div id="queue_stack0" class="stack">
10
</div>
<div id="queue_stack1" class="stack">
10
</div>
<!-- <div id="stack2" class="stack">
10
</div> -->
<!-- <div id="3" class="stack">
10
</div> -->
</div>
<!-- <p style="text-align: center; position: relative; top: 10px;">Queue</p> -->
<p style="text-align: center; position: relative; top: 10px">Rare</p>
<p style="text-align: center;"><i id="in_with_queue"
style="font-size: 23px; position: relative; top: 2px;" class="fa-solid fa-arrow-up"></i></p>
</div>
</section>
</section>
<section style="display: flex; justify-content: space-between; padding-left: 20px;" id="form_section">
<!-- basic operations -->
<div id="stack_with_array_div" style="display: flex; flex-direction: column;">
<p
style="font-family:'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; font-weight: 500; font-size: 20px; padding-left: 20px;">
Basic Operations</p>
<div
style="padding: 30px; overflow-y: auto; padding: 20px; padding-top: 10px; background-color:rgba(99, 99, 99, 0); border-width: 2px; border-style: none; border-color: lightgray;">
<div class="">
<form action="" onsubmit="insertAtLast_with_queue(event)">
v = <input type="number" id="insertedValue_queue" required>
<input id="insertAtLastBtn_queue" type="submit" value="Enqueue">
</form>
</div>
<br>
<div class="">
<form action="" onsubmit="removeValue_with_queue(event)">
<input style="visibility: hidden;" type="number" id="number_queue">
<input style="position: relative;left: 27px;" id="removeBtn_queue" type="submit"
value="Dequeue">
</form>
</div>
</div>
</div>
<div id="note_pad_div1" style="display: none; flex-direction: column; padding-right: 30px;">
<p
style="font-family:'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; font-weight: 500; font-size: 20px; padding-left: 0px;">
Explanation</p>
<div id="note_pad1"
style="width:400px; background-color: rgb(229, 229, 229); padding: 20px; padding-top: 20px;">
</div>
</div>
</section>
</section>
</section>
<script src="javascript/queue.js"></script>
<script src="javascript/withStack.js"></script>
<script>
let withArray_btn = document.getElementById('stack_with_array_btn')
let withQueue_btn = document.getElementById('stack_with_queue_btn')
let withLL_btn = document.getElementById('stack_with_ll_btn')
let withArray_div = document.getElementById('stack_with_array')
let withQueue_div = document.getElementById('stack_with_queue')
let withLL_div = document.getElementById('stack_with_ll')
let note_pad_div = document.getElementById('note_pad_div')
function resetAllForms() {
const forms = document.querySelectorAll('form');
forms.forEach(form => form.reset());
}
// basic operations btn
withArray_btn.addEventListener('click', () => {
withArray_div.style.display = 'block'
withQueue_div.style.display = 'none'
withLL_div.style.display = 'none'
resetAllForms()
note_pad_div.style.display = 'none'
localStorage.setItem('which', 'witharray')
})
// speacial operations btn
withQueue_btn.addEventListener('click', () => {
withQueue_div.style.display = 'block'
withArray_div.style.display = 'none'
withLL_div.style.display = 'none'
resetAllForms()
note_pad_div.style.display = 'none'
localStorage.setItem('which', 'withqueue')
})
// serach operations btn
withLL_btn.addEventListener('click', () => {
withLL_div.style.display = 'block'
withQueue_div.style.display = 'none'
withArray_div.style.display = 'none'
resetAllForms()
note_pad_div.style.display = 'none'
localStorage.setItem('which', 'withll')
})
</script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"
integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz"
crossorigin="anonymous"></script>
</body>
</html>