1)      a .Using the ADT approach write a pseudocode that describe an algorithm readAndCorrect that reads a string of characters, correcting mistakes along the way.

b.For the following input line, trace the execution of readAndCorrect and show the contents of the stack at each step:

ab         cde                fgh          i

c. The nature of the stack-based algorithm makes it simple to display the string in                reverse order,but somewhat hard to display in the correct order. Write a pseudocode algorithm called displayForward that displays the string in its correct forward order.

d.implement readAndCorrect and displayForward as java methods.

2) For each of the following strings,trace the execution of the language-recognition       algorithm and show the contents of the stack at each step .

a.xy$yxz

b.xy$yx

c.xyz$zxy

d.zzz$zz

e.xyzzy

3) Write a pseudocode method that uses a stack to determine whether a string is in the language L,where

a. L={w:w contains equal numbers of A



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *