Skip to content

Commit 51ac3ad

Browse files
committed
Stack QUEUE Added
1 parent ffc1e2b commit 51ac3ad

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed
File renamed without changes.

MISC/Stack.ipynb

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 1,
6+
"metadata": {},
7+
"outputs": [
8+
{
9+
"name": "stdout",
10+
"output_type": "stream",
11+
"text": [
12+
"3\n",
13+
"Popped: 3\n",
14+
"Popped: 2\n",
15+
"1\n",
16+
"Peek: 1\n",
17+
"1\n"
18+
]
19+
}
20+
],
21+
"source": [
22+
"\n",
23+
"class Stack:\n",
24+
"\n",
25+
" def __init__(self):\n",
26+
" self.stack = []\n",
27+
" \n",
28+
" def isEmpty(self):\n",
29+
" return self.stack == []\n",
30+
"\n",
31+
" def push(self, data):\n",
32+
" self.stack.append(data)\n",
33+
"\n",
34+
" def pop(self):\n",
35+
" data = self.stack[-1]\n",
36+
" del self.stack[-1]\n",
37+
" return data\n",
38+
"\n",
39+
" def peek(self):\n",
40+
" return self.stack[-1]\n",
41+
"\n",
42+
" def sizeStack(self):\n",
43+
" return len(self.stack)\n",
44+
" \n",
45+
"stack = Stack()\n",
46+
"stack.push(1)\n",
47+
"stack.push(2)\n",
48+
"stack.push(3)\n",
49+
"print(stack.sizeStack())\n",
50+
"print(\"Popped: \", stack.pop())\n",
51+
"print(\"Popped: \", stack.pop())\n",
52+
"print(stack.sizeStack())\n",
53+
"print(\"Peek:\", stack.peek())\n",
54+
"print(stack.sizeStack())"
55+
]
56+
}
57+
],
58+
"metadata": {
59+
"kernelspec": {
60+
"display_name": "Python 3",
61+
"language": "python",
62+
"name": "python3"
63+
},
64+
"language_info": {
65+
"codemirror_mode": {
66+
"name": "ipython",
67+
"version": 3
68+
},
69+
"file_extension": ".py",
70+
"mimetype": "text/x-python",
71+
"name": "python",
72+
"nbconvert_exporter": "python",
73+
"pygments_lexer": "ipython3",
74+
"version": "3.7.4"
75+
}
76+
},
77+
"nbformat": 4,
78+
"nbformat_minor": 4
79+
}

0 commit comments

Comments
 (0)