Question: Code required in python. Extending from Queue class: class CircularQueue: def __init__(self, size): self.size = size self.queue = [] def enqueue(self, item): if(len(self.queue))== self.size: raise

Code required in python.

Extending from Queue class:

class CircularQueue: def __init__(self, size): self.size = size self.queue = [] def enqueue(self, item): if(len(self.queue))== self.size: raise IndexError("The queue is full.") else: self.queue.append(item) def dequeue(self): if len(self.queue) ==0: raise IndexError("The queue is empty.") else: item = self.queue[0] del self.queue[0] return item def peek(self): if len(self.queue) ==0: raise IndexError("The queue is empty.") else: return self.queue[0]

Code required in python. Extending from Queue class: class CircularQueue: def __init__(self,

Extend the Queue class by adding the method splice(self, second_queue). The splice method combines two queues by adding all elements of a second queue to the end of the first queue. The second queue should not be altered when the method completes. For full credit, you must take advantage of being able to directly access the elements of second_queue You should include the entire Queue class definition in your answer to this question. For example: Modify the irculaQueue" class so the capacity automatically increases when you exceed the current capacity When you try to add an item to a full queue, the capacity should be doubled Test Result Do not decrease the capacity of the queue when you remove items from the queue. my queue-Queue() my queue.enqueue('1) my_queue.enqueue'2") my-queue. enqueue (3) another_queue - Queue() another_queue.e another_queue.enqueue( my queue.splice(another_queue) print (my_queue) print (another_queue) 5432 1 5 4 You should include the entire CircularQueue class definition in your answer to this question For example: Test Result CirculaQueue(2) | 3 20 30 40 q.enqueue(10) q.dequeue() q.enqueue(28) q.enqueue(3e) g.enqueue(40) print(a.size)) print(q.dequeue)) print(q.dequeue()) print (q.dequeue(O) my queue-Queue() my-queue. enqueue ( ' 4 . ) my queue.enqueue5) another-queue Queue() my queue.splice(another_queue) print (my_queue) 5 4 Answer (penalty regime: 0 %) 1 -lklass CircularQueue: palindrome is a sequence of words that reads the same as the sequence in reverse: for example, "noon is a palindrome whereas noone is not. Single character is also palindrome. Write a function, is_palindrome(s), which takes a string, s, as a parameter and determines whether the string is a palindrome or not. Ignore spaces and all punctuation symbols. You can assume that all characters are in lower case. You must make use of a deque to test the parameter string Note: you will be defining a function that USES the Deque ADT. The implementation of the Deque ADT is provided to you as part of this exercise. You can simply use Deque(), add_rear(), remove_front(), remove_rear) and size() as necessary in your function definition For example: Test Result print(is palindrome("abcdefFalse print (is_palindrome("no,on")) ruc

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!