Question: Write a C++ program to implement a queue using linked lists. You can use the queue data structure from the Standard Template Library (STL). The

Write a C++ program to implement a queue using linked lists. You can use the queue data structure from the Standard Template Library (STL).

The program should provide the following functionality:

  • Enqueue data into queue
  • Dequeue data from queue
  • Print data at the front
  • Print data at the back
  • Print the entire queue
  • Check if the queue is empty
  • Print the number of elements in the queue

Test your program using at least the following test cases (considering the queue includes integers):

  1. Check if the queue is empty
  2. Enqueue 7 into the queue
  3. Enqueue 4 into the queue
  4. Check if the queue is empty
  5. Dequeue data form the queue.
  6. Print the number of elements in the queue
  7. Enqueue 5 into the queue.
  8. Print the number of elements in the queue
  9. Check if the queue is empty
  10. Print data at the front
  11. Print data at the back
  12. Print entire queue

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!