Login or Create an Account to view the mark scheme, comment, and add to a test
The functions LENGTH(str) and TAIL(str) return the length and tail of the string str, respectively. Use LENGTH and TAIL to construct a recursive algorithm called reduce(str) to return a new string equal to a copy of the input string str only excluding any consecutive duplicate. For example, the following code will result in X equal to "AYN7AB":
X = reduce("AAYNNN77AB")

Short Answer3 MarksPremium
1 Use8 Views0 Likes