Question: Stack Class ADT Class Stack Node Class ADT class Node { public: dataType data; Node *next; }; public: Node *stackArr; int top; int size; Stack(int);

 Stack Class ADT Class Stack Node Class ADT class Node {

Stack Class ADT Class Stack Node Class ADT class Node { public: dataType data; Node *next; }; public: Node *stackArr; int top; int size; Stack(int); void push(Node*); Node* pop() bool isEmpty(); }; Linked List Class ADT class List { public: Node *head; List(); void insert_end(dataType); bool isEmpty(); }; Considering the given ADTs, use only the attributes and member functions outlined to create a non-member C++ function Node* reverse List(Node *head) that takes a non-empty list as argument and reverses it by using a stack. The basic algorithm of the function is given as follows: i. ii. iii. iv. V. Count the number of nodes in the input list. Create a stack of equal size. Push each node of the input list into the stack (one at a time). Create an empty list. Pop all nodes from the stack (one at a time) and attach at the end of the new list, until the stack is empty. Return the head of the reversed list. vi

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!