Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

[Coding] Zapis A regular bracket-sequence is a string of characters consisting only of opening and closing brackets, and satisfying the following conditions: - An empty

[Coding] Zapis

A regular bracket-sequence is a string of characters consisting only of opening and closing brackets, and satisfying the following conditions:

- An empty string is a regular bracket-sequence.

- If A is a regular bracket-sequence, then (A), [A] and {A} are also regular bracket-sequences.

- If A and B are regular bracket-sequences, then AB is also a regular bracket-sequence.

For example, the sequences [({})], [](){} and [{}]()[{}] are regular, but the sequences [({{([, []({)} and [{}])([{}] are not.

Ivica has found a string which looks like it could be a regular bracket-sequence. Some of the characters have become smudged and illegible, and could have been any character.

Write a program (Python or Java or C++) that calculates how many ways the illegible characters in the string can be replaced by brackets so that the result is a regular bracket-sequence. This number can be very large, so output only its last 5 digits.

Input

The first line contains an even integer image text in transcribed , the length of the string. The second line contains the string. Illegible characters are represented by the image text in transcribed character.

Output

Output the number of regular bracket-sequences the string could have read.

(Don't answer by hand-writing)

image text in transcribed

N 2 SNS 2000

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

Guide To Client Server Databases

Authors: Joe Salemi

2nd Edition

1562763105, 978-1562763107

More Books

Students also viewed these Databases questions

Question

Determining how many people will lose their jobs.

Answered: 1 week ago

Question

1. Identify what positions are included in the plan.

Answered: 1 week ago