5

Generic Double Ended Queue (Id-)

Bonus Practice Sheet Winter 2018 [17-Mar-2018 to 7-Apr-2018]

Program ID-

Design a generic class queue to maintain a list of elements. Queue is a linear data structure that follow FIFO ordering of elements. It is a special kind of list where elements can be inserted at one end and deleted at the end. There are two end points called front and rear. Front is the point of deletion and that move for each deletion but always points to the element that was inserted first among the elements remaining in the queue. Rear is the point of the insertion and move for each insertion but always points to the element that was inserted last among the elements remaining in the queue. Provide member functions to check if a queue is empty, queue is full, enqueue and dequeue.

Code

Please Comment Working if the code worked to you

If you have other working codes please comment the codes enclosing with <pre> and </pre> 🙂

Example: <pre> Your Code </pre>

C++ Code 

The Above Codes are for reference only. It doesn't mean everyone to directly copy/paste those codes.

 

Click Here to Leave a Comment Below 5 comments
s# - March 27, 2018

can you please give the code for chess, carom and scrabble players and generic right shift.




3



0

Reply
Spiderman - March 27, 2018

pushB – push_Back
pushF – push_Front
popF – pop_Front
popB – pop_Back

According to given code in the question, these are the function names.




0



0

Reply
Pranat Jain - March 27, 2018

It is not running

/tmp/tmpcFEEUQ/Hello.cpp:90:46: error: no ‘bool deque::pushB(T)’ member function declared in class ‘deque’
template bool deque::pushB(T data) {
^
/tmp/tmpcFEEUQ/Hello.cpp:93:46: error: no ‘bool deque::pushF(T)’ member function declared in class ‘deque’
template bool deque::pushF(T data) {
^
/tmp/tmpcFEEUQ/Hello.cpp:107:36: error: no ‘T deque::popF()’ member function declared in class ‘deque’
template T deque::popF() {
^
/tmp/tmpcFEEUQ/Hello.cpp:110:36: error: no ‘T deque::popB()’ member function declared in class ‘deque’
template T deque::popB() {
^




0



0

Reply
pokemon - March 28, 2018

Expected Output:
Empty
Not full
1
1
2
3
1
2
1
Box empty

Your Program Output:
Empty
Not full
1
1
2
Segmentation fault (core dumped)

pls see to it




0



0

Reply
hari - April 1, 2018

generic code is not working
/tmp/tmpAfqrzL/Hello.cpp:41:6: error: redefinition of ‘bool ERR_Flag’
bool ERR_Flag = false;
^
/tmp/tmpAfqrzL/Hello.cpp:5:6: note: ‘bool ERR_Flag’ previously defined here
bool ERR_Flag = false;
^
/tmp/tmpAfqrzL/Hello.cpp:43:7: error: redefinition of ‘class queue’
class queue
^
/tmp/tmpAfqrzL/Hello.cpp:7:7: error: previous definition of ‘class queue’
class queue
^
/tmp/tmpAfqrzL/Hello.cpp:63:7: error: redefinition of ‘class deque’
class deque:public queue
^
/tmp/tmpAfqrzL/Hello.cpp:29:7: error: previous definition of ‘class deque’
class deque:public queue
^
/tmp/tmpAfqrzL/Hello.cpp: In function ‘int main()’:
/tmp/tmpAfqrzL/Hello.cpp:254:5: error: redefinition of ‘int main()’
int main()
^
/tmp/tmpAfqrzL/Hello.cpp:155:5: note: ‘int main()’ previously defined here
int main()
^




0



0

Reply

Leave a Reply:

This site uses cookies and by using the site you are consenting to this.