I want to code this for PDA. How would I do that in C#?
a^nbc^n (n>=0)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Algorithm:
Read one letter at a time from the input, in a loop.
Stage 1:
If the letter read is “a” then increment a counter, and repeat Stage 1. If the letter read is not “a” then proceed to the next part.
Stage 2:
If the letter read is “b” then proceed to the next stage. If the letter read is not “b” then the algorithm fails.
Stage 3:
If if the letter read is “c” then decrement the counter, and repeat Stage 3. If the letter read is not “c” then proceed to the next stage.
Stage 4:
If the counter is zero, then the algorithm succeeds, otherwise it fails.