If s is a string, define its reverse s^R as follows. Compute (cubs)^R. Justify each step using the definition.

Jamya Shea

Jamya Shea

Open question

2022-08-18

If s is a string, define its reverse sR as follows.
B.λR=λR.If s has one or more symbols, write s=ra where a is a symbol and r is a string (possibly empty). Then sR=(ra)R=arR.
Compute (cubs)R. Justify each step using the definition.

Answer & Explanation

Gustavo Zimmerman

Gustavo Zimmerman

Beginner2022-08-19Added 14 answers

Here, we need to compute the reverse of a stringusing the given definition of R and B. R is the recursive definition in which the last symbol is made the first symbol and R is applied on the rest of the string. The base case here that of the empty symbol i.e λ which is given in part B.
1. In the first step, R is applied on ''cubs'' which makes the symbol ''s'' to be the first symbol and then recursively R will be applied on ''cub''
2. Similar to step 1, R is applied on ''cub'' and after ''s'', the next symbol will be ''b'' i.e. ''sb'' . R will now be applied on ''cu''
3. Again, after applying R on ''cu'' , we get the next symbol to be ''u'' i.e ''sbu''. R will now be applied on ''c''.
4. Since, ''c'' is the last symbol, an empty stringsymbol is inserted before ''c'' so that R can beapplied. This makes it ''λc''. Now R will be appliedon this.
5. After applying R, we get ''c'' to be the next symboli.e. ''sbuc''. Now we are left with λ.
6. Apply part B on λ which will give λ again.
7. Since λ is the empty string, it can be removed. Therefore, remove it. The reversed string becomes. ''sbuc''.
cubsR
=s(cub)R
=sb(cu)R
=sbu(c)R
=sbu(λc)R
=sbuc(λ)R
=sbuc(λ
=sbuc

Do you have a similar question?

Recalculate according to your conditions!

New Questions in Discrete math

Ask your question.
Get an expert answer.

Let our experts help you. Answer in as fast as 15 minutes.

Didn't find what you were looking for?