Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
62 lines (45 loc) · 1.27 KB

File metadata and controls

62 lines (45 loc) · 1.27 KB
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
60
61
62
import os
import sys
sys.path.append(os.path.dirname(os.path.abspath(os.path.dirname(__file__))))
from DoublyLinkedList.DoublyLinkedList import DoublyLinkedList
from DoublyLinkedList.DoublyLinkedList import Node
class ArrayStack:
def __init__(self):
self.data = []
def size(self):
return len(self.data)
def isEmpty(self):
return self.size() == 0
def enqueue(self, item):
self.data.append(item)
def dequeue(self):
return self.data.pop(0)
def peek(self):
return self.data[0]
class LinkedListQueue:
def __init__(self):
self.data = DoublyLinkedList()
def size(self):
return self.data.getLength()
def is_Empty(self):
return self.data.getLength() == 0
def enqueue(self, item):
newNode = Node(item)
return self.data.insertAt(self.data.nodeCount + 1, newNode)
def dequeue(self):
return self.data.popAt(1)
def peek(self):
return self.data.getAt(1).data
if __name__ == "__main__":
q = LinkedListQueue()
q.enqueue(1)
q.enqueue(2)
print(q.data)
print(q.is_Empty())
print(q.size())
print(q.peek())
print(q.dequeue())
print(q.dequeue())
print(q.data)
print(q.peek())
print(q.is_Empty())
Morty Proxy This is a proxified and sanitized view of the page, visit original site.