FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python/stack.py at data-struct · CheetahAzure/python · GitHub
CheetahAzure
/
python
Public
forked from
flypythoncom/python
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
python
/
stack.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
59 lines (45 loc) · 1.13 KB
Breadcrumbs
python
/
stack.py
Copy path
File metadata and controls
59 lines (45 loc) · 1.13 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
class
Stack
:
def
__init__
(
self
,
size
=
20
):
self
.
stack
=
[]
self
.
size
=
size
;
self
.
top
=
-
1
def
setSize
(
self
,
size
):
self
.
size
=
size
;
def
push
(
self
,
element
):
if
self
.
isFull
():
raise
"StackOverflow"
else
:
self
.
stack
.
append
(
element
)
self
.
top
=
self
.
top
+
1
def
pop
(
self
):
if
self
.
isEmpty
():
raise
"StackUnderflow"
else
:
element
=
self
.
stack
[
-
1
]
self
.
top
=
self
.
top
-
1
;
del
self
.
stack
[
-
1
]
return
element
def
Top
(
self
):
return
self
.
top
def
empty
(
self
):
self
.
stack
=
[]
self
.
top
=
-
1
def
isEmpty
(
self
):
if
self
.
top
==
-
1
:
return
True
else
:
return
False
def
isFull
(
self
):
if
self
.
top
==
self
.
size
-
1
:
return
True
else
:
return
False
if
__name__
==
"__main__"
:
stack
=
Stack
()
for
i
in
range
(
10
):
stack
.
push
(
i
)
print
stack
.
Top
()
for
i
in
range
(
10
):
print
stack
.
pop
()
stack
.
empty
()
print
stack
.
Top
()
Back
|
FazBrowse Home
|
New Git URL