Q:Question:(FIFO) Second -> Third -> last-in -> none Queue Front is now: Second Queue Rear is now:
Question:
uild a queue DS from a Queue class that has the following methods
Enqueue (data)
Dequeue()
is_empty()
peek()
__repr__()
Result:
Queue is_empty? True
peek the Queue: None
The queue is: ['last in', 'third', 'second', 'first in']
False
front is first in
dequeue the first item: first in
['last in', 'third', 'second']
b) Build a queue DS using a Singly Linked List class that has the following
methods: (use Queue_SLL.py)
Enqueue (data)
Dequeue()
in_empty()
peek()
__repr__()
Result:
First-in -> Second -> Third -> last-in -> none
Remove (DeQueue the front one (FIFO)
Second -> Third -> last-in -> none
Queue Front is now: Second
Queue Rear is now: last-in
add a list of number to the queue
Second -> Third -> last-in -> 0 -> 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7 -> 8 -> 9 -> none
Queue Rear is: now 9
c) Build a queue DS using the Collections.deque (use Queue.deque.py)
ResultsI
nitial queue
deque(['first in', 'second', 'third', 'last out'])
Elements dequeued from the queue
first in
after popLeft() : deque(['second', 'third', 'last out'])
second
third
Queue after removing elements
deque(['last out'])
Linear Algebra And Its Applications
ISBN: 9781292351216
6th Global Edition
Authors: David Lay, Steven Lay, Judi McDonald