Answered step by step
Verified Expert Solution
Question
1 Approved Answer
You have to complete program in this ADT's Node Class ADT class Node { public: dataType data; Node *next; }; Stack Class ADT Class Stack
You have to complete program in this ADT's
Node Class ADT class Node { public: dataType data; Node *next; }; Stack Class ADT Class Stack { 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* reverseList(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. Count the number of nodes in the input list. ii. Create a stack of equal size. Push each node of the input list into the stack (one at a time). iv. 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. vi. Return the head of the reversed list. iii. VStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started