Skip to content

Releases: Sustainability4/Data-Structure-Algorithms

Recursion:DS ALGO

18 Apr 18:27
6fa4694
Compare
Choose a tag to compare
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.