Question: **I need a python program, must be Python. (i'm studying python) :) I want a PYTHON program that prints out all the sequences possible, when

**I need a python program, must be Python. (i'm studying python) :)

I want a PYTHON program that prints out all the sequences possible, when number 1~5 is rearranged using stack or queue. Stack and Queue can hold at the maximum, two numbers.

For example, push(1) ? queue(2) ? dequeue() : seq = '2' ? push(3) ? pop() : seq = '23' ? queue(4) ? queue(5) ? pop() : seq = '231' ? dequeue() : seq = '2314' ? dequeue() : seq = '23145' could be a sequence.

When programming we must use RECURSION **I need a python program, must be Python. (i'm studying python) :)I want a PYTHON program that prints out all the sequences possible,when number 1~5 is rearranged using stack or queue. Stack and Queuecan hold at the maximum, two numbers. For example, push(1) ? queue(2)

class Queue: def init self, buffer size - 2): self. items = [ ] self.buf size -buffer size def is_empty(self): def is_full (self): def enqueue (self, item): return self.items -- [] return self.size() --self.buf size if self.is full(): print( full') return self.items.insert (0,item) def dequeue(self): if self.is empty (): print( 'empty' ) return self.items.pop() def size (self): return len(self.items) class Queue: def init self, buffer size - 2): self. items = [ ] self.buf size -buffer size def is_empty(self): def is_full (self): def enqueue (self, item): return self.items -- [] return self.size() --self.buf size if self.is full(): print( full') return self.items.insert (0,item) def dequeue(self): if self.is empty (): print( 'empty' ) return self.items.pop() def size (self): return len(self.items)

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!