Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

These are C++ ( Computer Science II ) programming problem. Please provide the de

ID: 3582815 • Letter: T

Question

These are C++ ( Computer Science II ) programming problem. Please provide the detailed answer the following problems.

Write the implementation of a code, that will print a linked list in reverse order by using a stack.

Explanation / Answer

program:implementation of linked list in reverse order using a stack #include #include using namespace std; class LinkedList { public: LinkedList() { head = NULL; } void addItem(string x) { if(head == NULL) { head = new node(); head->next = NULL; head->data = x; } else { node* temp = head; while(temp->next != NULL) temp = temp->next; node* newNode = new node(); newNode->data = x; newNode->next = NULL; temp->next = newNode; } } void printList() { node *temp = head; while(temp != NULL) // don't access ->next { cout data = x; } int countItems() { int count = 1; for(node* temp = head; temp->next != NULL; temp = temp->next) ++count; return count; } void printReverse() { node* temp2; node* temp = head; while(temp->next != NULL) temp = temp->next; //Print last node before we enter loop cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote