Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Suppose that someone marks every time the price of a share increases (I) by $1 and decreases (D) by $1. As a result, you

1. Suppose that someone marks every time the price of a share increases (I) by $1 and decreases (D) by $1. As a result, you get a sequence like IDII. Based on the sequence, we want to detect whether eventually, the price increased, i.e., whether the sequence contained more increases than decreases. Prove that the language of all the sequences corresponding to eventual increase is not regular.

2. Show, step by step, how the following pushdown automaton -- that checks whether a word consisting of letters I and D describes a share whose price increases -- will accept the word IDII. This pushdown automaton has three states:

the starting state s,

the working state w, and

the final state f.

In the stack, in addition to the bottom symbol $, we have:

either one or several I's -- indicating by how much the price of the stock increased so far,

or one or several D's -- indicating by how much the price of the stock decreased so far.

The transitions are as follows:

From s to w, the transition is , $.

From w to f, the transition is: , I .

From f to f, we have two transitions: , I and , $ .

From w to w, we have the following transitions:

If we see the symbol I and $ is on top of the stack, we keep the dollar sign and add I to the stack, i.e., we have transition I, $ $ that brings us to an intermediate state a1, and then the transition , I that brings us back to the working state.

If we see the symbol I and I is on top of the stack, we keep the top I and add another I to the stack, i.e., we have transition I, I I that brings us to an intermediate state a2, and then the transition , I that brings us back to the working state.

If we see the symbol I and D is on top of the stack, we delete the top D, i.e., we have transition I, D .

If we see the symbol D and $ is on top of the stack, we keep the dollar sign and add D to the stack, i.e., we have transition D, $ $ that brings us to an intermediate state a3, and then the transition , D that brings us back to the working state.

If we see the symbol D and D is on top of the stack, we keep the top D and add another D to the stack, i.e., we have transition D, D Dthat brings us to an intermediate state a4, and then the transition , D that brings us back to the working state.

If we see the symbol D and I is on top of the stack, we delete the top I, i.e., we have transition D, I .

3. Show, step by step, how the following grammar describing valid names for variables in an alphabet consisting of 0, 1, and a will generate the word a01. In this grammar, N stands for names, L for letters, and D for digits. The rules are: N L, N NL, N ND, L a, D 0, and D 1.

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

Learning MySQL Get A Handle On Your Data

Authors: Seyed M M Tahaghoghi

1st Edition

0596529465, 9780596529468

More Books

Students also viewed these Databases questions

Question

3. Would you say that effective teamwork saved their lives?

Answered: 1 week ago