FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Basic-Python-Programs/Queue_using_LL.py at patch-2 · aayush-0131/Basic-Python-Programs · GitHub
aayush-0131
/
Basic-Python-Programs
Public
forked from
souravjain540/Basic-Python-Programs
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Basic-Python-Programs
/
Queue_using_LL.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
39 lines (34 loc) · 989 Bytes
Breadcrumbs
Basic-Python-Programs
/
Queue_using_LL.py
Copy path
File metadata and controls
39 lines (34 loc) · 989 Bytes
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
class
Node
:
def
__init__
(
self
,
data
=
None
):
self
.
data
=
data
self
.
next
=
None
class
Queue
:
def
__init__
(
self
):
self
.
head
=
None
self
.
last
=
None
def
enqueue
(
self
,
data
):
if
not
self
.
last
:
self
.
head
=
Node
(
data
)
self
.
last
=
self
.
head
else
:
self
.
last
.
next
=
Node
(
data
)
self
.
last
=
self
.
last
.
next
def
dequeue
(
self
):
if
not
self
.
head
:
return
None
val
=
self
.
head
.
data
self
.
head
=
self
.
head
.
next
return
val
def
display
(
self
):
temp
=
self
.
head
while
temp
!=
None
:
print
(
temp
.
data
)
temp
=
temp
.
next
x
=
Queue
()
# Creating object of queue class
x
.
enqueue
(
1
)
# Add 1 to the queue
x
.
enqueue
(
2
)
# Add 2 to the queue
x
.
display
()
# 1 => 2
print
(
x
.
dequeue
())
# Deleting the first element of the queue.
x
.
display
()
# 2
print
(
x
.
dequeue
())
# 2
print
(
x
.
dequeue
())
# None(because queue is already empty)
Back
|
FazBrowse Home
|
New Git URL