Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have a c++ homework where i have to check given entry of parentheses are closed are not (we are not talking about balanced parentheses

I have a c++ homework where i have to check given entry of parentheses are closed are not (we are not talking about balanced parentheses but closed parentheses). I have to use a Stack in order to do this; however, this stack does not use a linked list for doing its operations, it uses two queues for operations. These 2 queues use singly linked list and takes 'char' for operations. There is also a function in main driver that checks the given input of parentheses are closed or not using stack and queues defined above. In the main function, input will be taken and the function above will decide if the input is closed or not. We have to use Node struct, Stack class and a Queue class. Node (struct) is expected to keep variables: (methods have to be defined/written like functions)

1) Char as a value

2) Address of the next queue node

Queue class is expected to keep variables and methods:

1) Address of the head queue node

2) Address of the tail queue node

3) enqueue()

4) dequeue()

5) front()

6) isempty()

7) clear()

Stack class is expected to keep these variables and methods

1) queue1

2) queue2

3) push()

4) pop()

5 top()

6) isempty()

7) clear()

Output examples are like this:

- {[]} is closed

- {}[]() is not closed

- {() is not closed

- [(())] is closed

- {()}[] is not closed

Thanks in advance

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