If s is a string, define its reverse s^R as follows.\begin{array}{|c|c|}\hline B. & \lambda^R = \lambda \\ \hline R. &

aortiH

aortiH

Answered question

2021-05-16

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

Answer & Explanation

Ayesha Gomez

Ayesha Gomez

Skilled2021-05-17Added 104 answers

Here, using the definitions of R and B provided, we must compute the reverse of a string. The last symbol is turned into the first symbol in the recursive definition R, and R is then applied to the other symbols in the string. The base case here that of the empty symbol i.e λ which is given in part B. 
1. R is applied to "cubs" in the first step, making the letter "s" the first symbol, and then R is applied to "cub" recursively.
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 string symbol is inserted before "c" so that R can be applied. This makes it "λc". Now R will be applied on this. 
5. After applying R, we get "c" to be the next symbol i.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. Thus, 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?