Input Your program will take an arithmetic expression as a String input. For Example: 1. "1+2"(3/4)" 2. "1+2*[3*3+{4-5(6(7/8/9)+10)-11+(12*8)]+14" 3. "1+2*[3*3+{4-5(6(7/8/9)+10)}−11+(12*8)/{13+13}]+14" Program Your program will determine whether the open brackets (the square brackets, curly braces and the parentheses) are closed in the correct order. Outputs: Output 1 1+2*(3/4) This expression is correct. Output 2 1+2*[3*3+{4-5(6(7/8/9)+10)-11+(12*8)]+14 This expression is NOT correct. Error at character # 10. "{'- not closed. Output 3 1+2*[3*3+{4-5(6(7/8/9)+10)}−11+(12*8)/{13+13}]+14 This expression is correct. Output 4 1+2] [3*3+{4-5(6(7/8/9)+10)−11+(12*8)]+14 This expression is NOT correct. Error at character # 4. '1'- not opened. Task 1

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
  1. Students might find it difficult to implement stack using array or linked list or both. For example, in array based implementation, students have to check for stack overflow and underflow exceptions. Also, in case of linked list based implementation, only stack underflow condition needs to be checked.

Solutions:

  1. Students have to create class for stack related exceptions. Two different classes can be declared, one for overflow and one for underflow. Both classes need to extend the Exception class of Java.
  2. Put stack’s push and pop methods inside a try-catch block and handle the exceptions.
  1. It can get difficult or confusing to check all conditions of parenthesis matching. Because, when a closing parenthesis/curly brace/bracket is encountered one needs to make sure the correct type of opening parenthesis/curly brace/bracket are popped from the stack
  2.  

Solutions:

  1. Students need to write if-else if checking for each type of parenthesis/curly brace/bracket separately when an opening parenthesis/curly brace/bracket is encountered.
  2. Also, a method to check whether the stack is empty after reading all inputs needs to be implemented.

    1. Complete the following problem using concepts of STACK, 
    2. You may use python language to complete the tasks.
    3. You need to create a full functioning Stack data structure to solve this problem. You are not allowed to use the built in Stack.
Input
Your program
1. "1+2*(3/4)"
2. "1+2*[3*3+{4-5(6(7/8/9)+10)−11+(12*8)]+14"
3. "1+2*[3*3+{4-5(6(7/8/9)+10)}−11+(12*8)/{13+13}]+14"
Program
will take an arithmetic expression as a String input. For Example:
Your program will determine whether the open brackets (the square brackets, curly braces and
the parentheses) are closed in the correct order.
Outputs:
Output 1
1+2*(3/4)
This expression is correct.
Output 2
1+2* [3*3+{4-5(6(7/8/9)+10)−11+(12*8)]+14
This expression is NOT correct.
Error at character # 10. *{*- not closed.
Output 3
1+2* [3*3+{4-5(6(7/8/9)+10)}−11+(12*8)/{13+13}]+14
This expression is correct.
Output 4
1+2]*[3*3+{4-5(6(7/8/9)+10)−11+(12*S)]+14
This expression is NOT correct.
Error at character # 4. *]*- not opened.
Task 1
Solve the above problem using an array based stack.
Task 2
Solve the above problem using a linked list based stack.
Transcribed Image Text:Input Your program 1. "1+2*(3/4)" 2. "1+2*[3*3+{4-5(6(7/8/9)+10)−11+(12*8)]+14" 3. "1+2*[3*3+{4-5(6(7/8/9)+10)}−11+(12*8)/{13+13}]+14" Program will take an arithmetic expression as a String input. For Example: Your program will determine whether the open brackets (the square brackets, curly braces and the parentheses) are closed in the correct order. Outputs: Output 1 1+2*(3/4) This expression is correct. Output 2 1+2* [3*3+{4-5(6(7/8/9)+10)−11+(12*8)]+14 This expression is NOT correct. Error at character # 10. *{*- not closed. Output 3 1+2* [3*3+{4-5(6(7/8/9)+10)}−11+(12*8)/{13+13}]+14 This expression is correct. Output 4 1+2]*[3*3+{4-5(6(7/8/9)+10)−11+(12*S)]+14 This expression is NOT correct. Error at character # 4. *]*- not opened. Task 1 Solve the above problem using an array based stack. Task 2 Solve the above problem using a linked list based stack.
Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY