ANSWER ASAP. C++ LANGUAGE ONLY. (NOT C, NOT JAVA, NOT C#) CPP ONLY Using the double-ended linked list C language syntax code below, convert it into C++ and use it as the base.  Modify the provided program into the ff: create a new class named student_queue. and then.. Implement the following methods for the class: front() - returns the pointer to the front element of the queue back() - returns the pointer to the back element of the queue push() - allocates memory for a new node and connects it to the existing queue pop() - retrieves the oldest node in the queue, copies the data to a structure, and frees up the memory from the queue empty() - returns 1 or 0 depending on whether the queue is empty or not size() - returns the number of elements in the queue Program code: #include #include typedef struct se_list_type { int num; struct se_list_type* prev; struct se_list_type* next; } se_list; int main() { // Start the list se_list* head = NULL; se_list* cur = NULL; // Create the first node head = (se_list*)malloc(sizeof(se_list)); head->num = 2; head->prev = NULL; head->next = NULL; cur = head; // Create the second node cur->next = (se_list*)malloc(sizeof(se_list)); cur->next->prev = cur; cur = cur->next; cur->num = 1; cur->prev = head; cur->next = NULL; // Create the third node cur->next = (se_list*)malloc(sizeof(se_list)); cur->next->prev = cur; cur = cur->next; cur->num = -5; cur->prev = head->next; cur->next = NULL; // Create 10 more random nodes srand(0); for (int i = 0; i < 10; i++) { cur->next = (se_list*)malloc(sizeof(se_list)); cur->next->prev = cur; cur = cur->next; cur->num = rand() % 20 - 10; cur->prev = cur->next; cur->next = NULL; } // Print the list forward cur = head; while (cur != NULL) { printf("%d ", cur->num); cur = cur->next; } printf("\n"); // Free the memory cur = head; while (cur != NULL) {  se_list* next = cur->next; free(cur); cur = next; } return 0; }   THANK YOU!

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter18: Stacks And Queues
Section: Chapter Questions
Problem 16PE: The implementation of a queue in an array, as given in this chapter, uses the variable count to...
icon
Related questions
icon
Concept explainers
Question
100%

ANSWER ASAP.

C++ LANGUAGE ONLY. (NOT C, NOT JAVA, NOT C#) CPP ONLY

Using the double-ended linked list C language syntax code below, convert it into C++ and use it as the base. 

Modify the provided program into the ff:

  • create a new class named student_queue.

and then..

  • Implement the following methods for the class:

  • front() - returns the pointer to the front element of the queue
  • back() - returns the pointer to the back element of the queue
  • push() - allocates memory for a new node and connects it to the existing queue
  • pop() - retrieves the oldest node in the queue, copies the data to a structure, and frees up the memory from the queue
  • empty() - returns 1 or 0 depending on whether the queue is empty or not
  • size() - returns the number of elements in the queue

Program code:

#include <stdio.h>
#include <stdlib.h>
typedef struct se_list_type {
int num;
struct se_list_type* prev;
struct se_list_type* next;
} se_list;
int main() {
// Start the list
se_list* head = NULL;
se_list* cur = NULL;
// Create the first node
head = (se_list*)malloc(sizeof(se_list));
head->num = 2;
head->prev = NULL;
head->next = NULL;
cur = head;
// Create the second node
cur->next = (se_list*)malloc(sizeof(se_list));
cur->next->prev = cur;
cur = cur->next;
cur->num = 1;
cur->prev = head;
cur->next = NULL;
// Create the third node
cur->next = (se_list*)malloc(sizeof(se_list));
cur->next->prev = cur;
cur = cur->next;
cur->num = -5;
cur->prev = head->next;
cur->next = NULL;
// Create 10 more random nodes
srand(0);
for (int i = 0; i < 10; i++) {
cur->next = (se_list*)malloc(sizeof(se_list));
cur->next->prev = cur;
cur = cur->next;
cur->num = rand() % 20 - 10;
cur->prev = cur->next;
cur->next = NULL;
}
// Print the list forward
cur = head;
while (cur != NULL) {
printf("%d ", cur->num);
cur = cur->next;
}
printf("\n");
// Free the memory
cur = head;
while (cur != NULL) {

 se_list* next = cur->next;
free(cur);
cur = next;
}
return 0;
}

 

THANK YOU!

Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Depth First Search
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning