Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

use scheme (k-palindrome? tahcohcat 2) #t (k-palindrome? tahcohcat 1) #f [5 marks] Write a procedure called (palindrome? s) that takes a string s as argument

use scheme (k-palindrome? "tahcohcat" 2)  #t (k-palindrome? "tahcohcat" 1)  #f 
  1. [5 marks] Write a procedure called (palindrome? s) that takes a string s as argument and returns true (#t) if s is palindrome.
  2. [7 marks] A k-palindrome is a string that can be made into a palindrome by ignoring up to k characters. Write a procedure called (k-palindrome? s k) that takes a string s and a non-negative integer k as arguments and returns true if s is a k-palindrome. For example,

You may find the following built-in procedures useful for the above problems:

  • (string-length str) - returns the number of characters in a given string
  • (string-ref str i) - returns the character at a specified index in a given string
  • (substring str start [end]) - returns a substring of a given string between two indices [the ending index is optional].

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions