Skip to content

Recursion:DS ALGO

Latest
Compare
Choose a tag to compare
@Sustainability4 Sustainability4 released this 18 Apr 18:27
· 188 commits to main since this release
6fa4694
Create string_condition_recursion.cpp

Suppose you have a string, S, made up of only 'a's and 'b's. Write a recursive function that checks if the string was generated using the following rules:
a. The string begins with an 'a'
b. Each 'a' is followed by nothing or an 'a' or "bb"
c. Each "bb" is followed by nothing or an 'a'
If all the rules are followed by the given string, return true otherwise return false.