in kotlin Write two versions of a recursive palindrome check function.  One version should have a block body, and the other should have an expression body.  Review the lecture slide about the substring function first.  Use this algorithm: if the length of the string is less than 2, return true else if the first and last characters are not equal (!=) return false else return the result of a recursive call with the substring from the second character (the one at index 1) to the second to last character. Use a main that uses a loop to test the palindrome function using this list of strings:     val ss = listOf("", "A", "AA", "AB", "AAA", "ABA", "ABB", "AAAA", "AABA", "ABBA", "ABCBA", "ABCAB")

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter15: Recursion
Section: Chapter Questions
Problem 6PE
icon
Related questions
Question

in kotlin

Write two versions of a recursive palindrome check function.  One version should have a block body, and the other should have an expression body.  Review the lecture slide about the substring function first.  Use this algorithm:

if the length of the string is less than 2, return true

else if the first and last characters are not equal (!=) return false

else return the result of a recursive call with the substring from the second character (the one at index 1) to the second to last character.

Use a main that uses a loop to test the palindrome function using this list of strings:

    val ss = listOf("", "A", "AA", "AB", "AAA", "ABA", "ABB", "AAAA", "AABA", "ABBA", "ABCBA", "ABCAB")

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Fibonacci algorithm
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage