Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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. V

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David M. Kroenke

12th Edition International Edition

1292023422, 978-1292023427

More Books

Students also viewed these Databases questions

Question

=+6. Why should they buy this product/service?

Answered: 1 week ago