Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Practical application 2 : Context - free language recognizer in java language. ( a ) Design an algorithm that recognizes ( accepts ) strings of
Practical application : Contextfree language recognizer in java language.a Design an algorithm that recognizes accepts strings of the following contextfree language: L nn : where n That is strings that contain a number of zerosfollowed by the same number of ones. Examples of strings in the language are: etc. Strings that are not in the language are, for example, and many more. The algorithm should take a string of s and s as input and output Yesif the string belongs to the language, and No if the string doesnt belong to the language.The algorithm should use a stack. When it reads a from the string, it pushes onto thestack. When it reads a it checks if the stack has a in which case that is popped fromthe stack. When the stack is empty and the end of the string is reached, the string isrecognized as correct Yes Otherwise, the string is not in the language Nob marks Implement the algorithm of a in your favorite programming language and runit on different strings as follows: and and others.c marks Consider an input string of size n: i what is the worstcase time that youralgorithm takes to decide whether or not the string belongs to the language? ii Why? Giveyour answers in terms of the Onotation.d bonus marks Run your algorithm on strings of lengths n Compute the running time in nanoseconds and draw a table with the results. Draw a table ora plot of the results for different values of n and compare the results obtained with thecomplexity you found in c Note: if all or most of the running times become tryrunning the program times and compute the average.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started