-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrouter_test.py
More file actions
111 lines (92 loc) · 2.36 KB
/
Copy pathrouter_test.py
File metadata and controls
111 lines (92 loc) · 2.36 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
'''
@author-name: Rishab Katta
'''
from stack import *
from queue import *
from ListQueue import *
from ListStack import *
def router_test():
'''
This function is written to test the implementations of Stack and Queue using Ringbuffer and Python List.
Performs various operations like insert, push, pop, enqueue, dequeue etc. I'm using ListStack and ListQueue as ref
to check if my implementations are correct or not.
'''
stack = Stack(20)
queue = Queue(20)
liststack = ListStack(20)
listqueue = ListQueue(20)
for i in range(20):
stack.push(i)
queue.enqueue(i)
liststack.insert(i)
listqueue.insert(i)
print(stack)
print(queue)
print(liststack)
print(listqueue)
for i in range(20,31):
stack.push(i)
queue.enqueue(i)
liststack.insert(i)
listqueue.insert(i)
print(" ")
print(stack)
print(queue)
print(liststack)
print(listqueue)
for _ in range(10):
stack.pop()
queue.dequeue()
liststack.remove()
listqueue.remove()
print(" ")
print(stack)
print(queue)
print(liststack)
print(listqueue)
for _ in range(10):
stack.pop()
queue.dequeue()
liststack.remove()
listqueue.remove()
print(" ")
print(stack)
print(queue)
print(liststack)
print(listqueue)
for _ in range(10):
stack.pop()
queue.dequeue()
liststack.remove()
listqueue.remove()
print(" ")
print(stack)
print(queue)
print(liststack)
print(listqueue)
for i in range(20):
queue.enqueue(i)
listqueue.insert(i)
print(" ")
print(queue)
print(listqueue)
print("Queue size: " + str(queue.queue_size()))
print(" ")
for _ in range(20):
stack.push(queue.peek())
liststack.insert(queue.peek())
queue.dequeue()
listqueue.remove()
print(stack)
print(liststack)
print("Stack size: " + str(stack.stack_size()))
for _ in range(20):
queue.enqueue(stack.peek())
listqueue.insert(stack.peek())
stack.pop()
print(" ")
print(queue)
print(listqueue)
print(queue.queue_size())
if __name__ == '__main__':
router_test()