We are given strings containing brackets of 4 types - round (), square [], curly {} and angle <> ones. The goal is to check, whether brackets are in correct sequence. I.e. any opening bracket should have closing bracket of the same type somewhere further by the string, and bracket pairs should not overlap, though they could be nested: {d/3}) here square and curly brackets are nested in the (a+[b*c] round ones -

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
Finally, complete the following programming task on https://play.kotlinlang.org and submit your
link to Blackboard. The input should be a string declared at the top of the file.
We are given strings containing brackets of 4 types - round (), square [], curly {} and
angle <> ones. The goal is to check, whether brackets are in correct sequence. I.e. any
opening bracket should have closing bracket of the same type somewhere further by the
string, and bracket pairs should not overlap, though they could be nested:
here square and curly brackets are nested in the
(a+[b*c] - {d/3})
round ones
(a+[b*c) 17]
does not make sense
Input data will contain a test-case in form of a character sequence.
Answer should contain 1 (if bracket order is correct) or 0 (if incorrect) for each of test-
cases, separated by spaces.
Example:
input data:
(a+[b*c]-{d/3})
*
here square brackets overlap with round ones which
(a + [b c)
(((a * x) + [b] y) + c
auf (zlo)men [gy<psy>] four {s}
answer:
1 0 0 1
17]
*
Transcribed Image Text:Finally, complete the following programming task on https://play.kotlinlang.org and submit your link to Blackboard. The input should be a string declared at the top of the file. We are given strings containing brackets of 4 types - round (), square [], curly {} and angle <> ones. The goal is to check, whether brackets are in correct sequence. I.e. any opening bracket should have closing bracket of the same type somewhere further by the string, and bracket pairs should not overlap, though they could be nested: here square and curly brackets are nested in the (a+[b*c] - {d/3}) round ones (a+[b*c) 17] does not make sense Input data will contain a test-case in form of a character sequence. Answer should contain 1 (if bracket order is correct) or 0 (if incorrect) for each of test- cases, separated by spaces. Example: input data: (a+[b*c]-{d/3}) * here square brackets overlap with round ones which (a + [b c) (((a * x) + [b] y) + c auf (zlo)men [gy<psy>] four {s} answer: 1 0 0 1 17] *
Expert Solution
steps

Step by step

Solved in 4 steps with 5 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