-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDataStructure_Presention.html
More file actions
447 lines (421 loc) · 18.3 KB
/
DataStructure_Presention.html
File metadata and controls
447 lines (421 loc) · 18.3 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Stack Implementation in C++</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/alpinejs/3.12.0/cdn.min.js" defer></script>
<style>
.fade-in { animation: fadeIn 0.5s ease-in-out; }
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
.progress-bar {
height: 6px;
background: linear-gradient(to right, #4F46E5, #10B981);
transition: width 0.3s ease;
}
.text-slide-in {
animation: textSlideIn 0.8s ease-out;
}
@keyframes textSlideIn {
from { opacity: 0; transform: translateX(-20px); }
to { opacity: 1; transform: translateX(0); }
}
.code-block {
background: #2d3748;
border-radius: 8px;
padding: 1rem;
overflow-x: auto;
}
.slide-content {
max-height: 70vh;
overflow-y: auto;
}
.slide-wireframe {
position: fixed;
right: 20px;
top: 50%;
transform: translateY(-50%);
background: rgba(45, 55, 72, 0.9);
border-radius: 8px;
padding: 10px;
width: 150px;
max-height: 80vh;
overflow-y: auto;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.slide-wireframe button {
display: block;
width: 100%;
padding: 8px;
margin: 4px 0;
background: #4a5568;
color: white;
border: none;
border-radius: 4px;
text-align: left;
cursor: pointer;
transition: background 0.3s ease;
}
.slide-wireframe button:hover {
background: #2d3748;
}
.slide-wireframe button.active {
background: #4F46E5;
}
/* Welcome Screen Styling */
.loading-page {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.8);
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
text-align: center;
color: white;
font-size: 2rem;
padding: 20px;
opacity: 1;
visibility: visible;
transition: opacity 1s ease-in-out;
z-index: 9999;
}
.loading-page.hidden {
opacity: 0;
visibility: hidden;
}
.loading-text {
font-size: 2.5rem;
font-weight: bold;
letter-spacing: 2px;
animation: textFadeIn 2s ease-in-out;
}
@keyframes textFadeIn {
0% { opacity: 0; transform: translateY(-20px); }
50% { opacity: 0.6; }
100% { opacity: 1; transform: translateY(0); }
}
.loading-logo {
width: 150px;
height: 150px;
background: url('https://via.placeholder.com/150') no-repeat center center;
background-size: contain;
margin-bottom: 30px;
animation: rotateLogo 2s infinite linear;
}
@keyframes rotateLogo {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
.loading-subtext {
font-size: 1.2rem;
font-weight: normal;
margin-top: 15px;
color: #ddd;
}
</style>
</head>
<body class="bg-gray-900 text-white" x-data="{ slide: 1, loading: true }" x-init="setTimeout(() => loading = false, 3000)">
<!-- Welcome Loading Screen -->
<div x-show="loading" class="loading-page">
<!-- Logo -->
<div class="loading-logo"></div>
<!-- Main Title -->
<h1 class="text-5xl font-bold text-blue-400 mt-8">
Stack Implementation in C++
</h1>
<!-- Course Info -->
<h2 class="text-2xl mt-3 text-gray-300">
Course: Data Structures
</h2>
<!-- Description -->
<p class="text-lg mt-3 text-white">
Using Arrays with push(), pop(), and display()
</p>
<!-- Presenter Information -->
<p class="mt-4 text-yellow-300">
Presented by: Nayan Kumar Ray & Heridoy Chowdhury
</p>
<!-- Loading Text -->
<div class="loading-text mt-6">
Welcome to the Stack Implementation in C++
</div>
<!-- Loading Animation with Text -->
<div class="flex items-center justify-center mt-3">
<!-- Spinner Animation -->
<div class="animate-spin border-t-4 border-blue-400 border-solid rounded-full w-12 h-12 mr-4"></div>
<div class="loading-subtext text-white">
Loading your experience, please wait...
</div>
</div>
</div>
<div x-show="!loading" class="flex flex-col items-center justify-center min-h-screen p-4">
<div class="w-full max-w-4xl p-6 bg-gray-800 rounded-xl shadow-lg text-center relative">
<!-- Progress Bar -->
<div class="w-full bg-gray-700 rounded-full h-2 mb-6">
<div class="progress-bar rounded-full" :style="`width: ${(slide / 12) * 100}%`"></div>
</div>
<!-- Slides -->
<div class="relative overflow-hidden">
<template x-for="n in 12" :key="n">
<div x-show="slide === n" class="fade-in">
<!-- Slide 1: Title Slide -->
<template x-if="slide === 1">
<div>
<h1 class="text-5xl font-bold text-blue-400">Stack Implementation in C++</h1>
<h2 class="text-2xl mt-3 text-gray-300">Course: Data Structures</h2>
<p class="text-lg mt-3">Using Arrays with push(), pop(), and display()</p>
<p class="mt-4 text-yellow-300">Presented by: Nayan Kumar Ray & Heridoy Chowdhury</p>
</div>
</template>
<!-- Slide 2: Introduction to Stack -->
<template x-if="slide === 2">
<div class="flex items-center">
<div class="w-1/2 pr-4">
<h2 class="text-3xl font-bold mb-4 text-slide-in">Introduction to Stack</h2>
<p class="text-lg mb-4 text-slide-in">A stack is a linear data structure that follows the <strong>LIFO (Last In, First Out)</strong> principle.</p>
<p class="text-lg text-slide-in">Common operations: <code class="bg-gray-700 px-2 py-1 rounded">push()</code>, <code class="bg-gray-700 px-2 py-1 rounded">pop()</code>, and <code class="bg-gray-700 px-2 py-1 rounded">display()</code>.</p>
<p class="text-lg mt-4 text-slide-in">Stacks are widely used in algorithms like <strong>Depth-First Search (DFS)</strong>, <strong>Expression Evaluation</strong>, and <strong>Backtracking</strong>.</p>
</div>
<div class="w-1/2">
<img src="https://media.geeksforgeeks.org/wp-content/cdn-uploads/20230726165552/Stack-Data-Structure.png" alt="Stack Data Structure" class="rounded-lg">
</div>
</div>
</template>
<!-- Slide 3: Stack Operations -->
<template x-if="slide === 3">
<div class="flex justify-between">
<div class="w-3/5">
<h2 class="text-3xl font-bold mb-4 text-slide-in">Stack Operations</h2>
<ul class="text-lg space-y-2 text-slide-in">
<li><strong>Push():</strong> Adds an element to the top of the stack.</li>
<li><strong>Pop():</strong> Removes the top element from the stack.</li>
<li><strong>Display():</strong> Displays all elements in the stack.</li>
<li><strong>Peek():</strong> Returns the top element without removing it.</li>
</ul>
<p class="text-lg mt-4 text-slide-in">These operations are essential for managing data in a stack efficiently.</p>
</div>
<div class="w-2/5">
<img src="assets\presention.jpg" alt="Stack Operations" class="w-full h-auto rounded-lg shadow-lg">
</div>
</div>
</template>
<!-- Slide 4: Stack Implementation -->
<template x-if="slide === 4">
<div class="flex justify-between">
<div class="w-3/5">
<h2 class="text-3xl font-bold mb-4 text-slide-in">Stack Implementation</h2>
<pre class="code-block text-slide-in">#include <iostream>
#define MAX 5</pre>
<p class="text-lg mt-4 text-slide-in">Defines the stack size and array implementation. The <code>MAX</code> constant ensures the stack has a fixed size.</p>
</div>
<div class="w-2/5">
<img src="assets\Stack Implementation.png" alt="Stack Implementation" class="w-full h-auto rounded-lg shadow-lg">
</div>
</div>
</template>
<!-- Slide 5: Stack Class Definition -->
<template x-if="slide === 5">
<div class="flex justify-between">
<div class="w-3/5">
<h2 class="text-3xl font-bold mb-4 text-slide-in">Stack Class Definition</h2>
<pre class="code-block text-slide-in">class Stack {
int top;
int arr[MAX];
public:
Stack() { top = -1; }
};</pre>
<p class="text-lg mt-4 text-slide-in">The <code>top</code> variable tracks the index of the top element, and <code>arr[MAX]</code> stores the stack elements.</p>
</div>
<div class="w-2/5">
<img src="assets\Stack Class Definition.png" alt="Stack Class Definition" class="w-full h-auto rounded-lg shadow-lg">
</div>
</div>
</template>
<!-- Slide 6: Push Operation -->
<template x-if="slide === 6">
<div class="flex justify-between">
<div class="w-3/5">
<h2 class="text-3xl font-bold mb-4 text-slide-in">Push Operation</h2>
<pre class="code-block text-slide-in">void push(int value) {
if (top >= MAX - 1) {
std::cout << "Stack Overflow\n";
return;
}
arr[++top] = value;
}</pre>
<p class="text-lg mt-4 text-slide-in">The <code>push()</code> function adds an element to the stack. If the stack is full, it displays a <strong>Stack Overflow</strong> error.</p>
</div>
<div class="w-2/5">
<img src="assets\Push Operation.png" alt="Push Operation" class="w-full h-auto rounded-lg shadow-lg">
</div>
</div>
</template>
<!-- Slide 7: Pop Operation -->
<template x-if="slide === 7">
<div class="flex justify-between">
<div class="w-3/5">
<h2 class="text-3xl font-bold mb-4 text-slide-in">Pop Operation</h2>
<pre class="code-block text-slide-in">void pop() {
if (top < 0) {
std::cout << "Stack Underflow\n";
return;
}
std::cout << arr[top--] << " popped from stack\n";
}</pre>
<p class="text-lg mt-4 text-slide-in">The <code>pop()</code> function removes the top element. If the stack is empty, it displays a <strong>Stack Underflow</strong> error.</p>
</div>
<div class="w-2/5">
<img src="assets\Pop Operation.png" alt="Pop Operation" class="w-full h-auto rounded-lg shadow-lg">
</div>
</div>
</template>
<!-- Slide 8: Display Function -->
<template x-if="slide === 8">
<div>
<h2 class="text-3xl font-bold mb-4 text-slide-in">Display Function</h2>
<pre class="code-block text-slide-in">void display() {
if (top < 0) {
std::cout << "Stack is empty\n";
return;
}
for (int i = top; i >= 0; i--)
std::cout << arr[i] << " ";
}</pre>
<p class="text-lg mt-4 text-slide-in">The <code>display()</code> function prints all elements in the stack from top to bottom.</p>
</div>
</template>
<!-- Slide 9: Main Function -->
<template x-if="slide === 9">
<div>
<h2 class="text-3xl font-bold mb-4 text-slide-in">Main Function</h2>
<pre class="code-block text-slide-in">int main() {
Stack s;
s.push(10);
s.push(20);
s.push(30);
s.display();
s.pop();
s.display();
return 0;
}</pre>
<p class="text-lg mt-4 text-slide-in">The <code>main()</code> function demonstrates the usage of the stack operations.</p>
</div>
</template>
<!-- Slide 10: Output Example -->
<template x-if="slide === 10">
<div>
<h2 class="text-3xl font-bold mb-4 text-slide-in">Output Example</h2>
<pre class="code-block text-slide-in">10 pushed into stack
20 pushed into stack
30 pushed into stack
Stack elements: 30 20 10
30 popped from stack
Stack elements: 20 10</pre>
<p class="text-lg mt-4 text-slide-in">This output shows the stack operations in action.</p>
</div>
</template>
<!-- Slide 11: Explanation for Lab Exam -->
<template x-if="slide === 11">
<div>
<h2 class="text-3xl font-bold mb-4 text-slide-in">Explanation for Lab Exam</h2>
<p class="text-lg text-slide-in">A stack is a data structure that follows the <strong>Last In, First Out (LIFO)</strong> principle. This means that the last element added is the first one to be removed.</p>
<p class="text-lg text-slide-in">We can implement a stack using an array with two main functions:</p>
<ul class="text-lg space-y-2 text-slide-in">
<li><code>push(value)</code> - Adds an element to the top of the stack.</li>
<li><code>pop()</code> - Removes and returns the top element from the stack.</li>
</ul>
<p class="text-lg mt-4 text-slide-in">Here is the C++ implementation:</p>
<pre class="code-block text-slide-in">#include <iostream>
#define MAX 100
using namespace std;
class Stack {
private:
int arr[MAX];
int top;
public:
Stack() { top = -1; }
void push(int value) {
if (top >= MAX - 1) {
cout << "Stack Overflow!" << endl;
return;
}
arr[++top] = value;
}
int pop() {
if (top < 0) {
cout << "Stack Underflow!" << endl;
return -1;
}
return arr[top--];
}
void display() {
if (top < 0) {
cout << "Stack is empty!" << endl;
return;
}
for (int i = 0; i <= top; i++) {
cout << arr[i] << " ";
}
cout << endl;
}
};
int main() {
Stack s;
s.push(10);
s.push(20);
s.push(30);
s.display();
cout << "Popped: " << s.pop() << endl;
s.display();
return 0;
}</pre>
<p class="text-lg text-slide-in mt-4">Key points to cover:</p>
<ul class="text-lg space-y-2 text-slide-in">
<li>The <strong>LIFO</strong> principle and its importance.</li>
<li>How <code>push()</code> and <code>pop()</code> maintain stack integrity.</li>
<li>Handling edge cases like stack overflow and underflow.</li>
</ul>
</div>
</template>
<!-- Slide 12: Conclusion & Questions -->
<template x-if="slide === 12">
<div>
<h2 class="text-3xl font-bold mb-4 text-slide-in">Conclusion & Questions</h2>
<p class="text-lg text-slide-in">Summary of Stack implementation in C++.</p>
<p class="text-lg mt-4 text-slide-in">Use cases:</p>
<ul class="text-lg space-y-2 text-slide-in">
<li><strong>Function Calls:</strong> Managing return addresses.</li>
<li><strong>Undo Feature:</strong> Reverting actions in applications.</li>
<li><strong>Expression Evaluation:</strong> Solving arithmetic expressions.</li>
</ul>
<p class="text-lg mt-4 text-slide-in">Questions? Feel free to ask!</p>
</div>
</template>
</div>
</template>
</div>
<!-- Navigation Buttons -->
<div class="mt-6 flex justify-between">
<button @click="if(slide > 1) slide--" class="bg-blue-500 px-4 py-2 rounded-lg hover:bg-blue-600 transition">Previous</button>
<button @click="if(slide < 12) slide++" class="bg-green-500 px-4 py-2 rounded-lg hover:bg-green-600 transition">Next</button>
</div>
</div>
<!-- Slide Wireframe on the Right -->
<div class="slide-wireframe">
<template x-for="n in 12" :key="n">
<button @click="slide = n" :class="{ 'active': slide === n }" class="text-sm">
Slide <span x-text="n"></span>
</button>
</template>
</div>
</div>
</body>
</html>