Question

In 1-3 sentences, describe how you would make a "Function that can test if an arbitrary...

In 1-3 sentences, describe how you would make a "Function that can test if an arbitrary string is a palindrome if stripped of punctuation", Recursively using C++

Homework Answers

Answer #1
  1. If the string has only one character, then return true.
  2. Else, if the string contains punctuation character, then remove the punctuation character.

Use ispunct() function.

int ispunct(int ch)

ch is the character to be checked. Function returns non-zero value, if ch is punctuation character otherwise zero is returned.

If non-zero value is returned, use string erase() function to remove the character.

str.erase(pos,len)

pos represents the position of the character to be removed. len represents number of characters to be removed from the pos.

3. After removing all punctuation charcters, compare first and last charcters of the substring recursively.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
In 1-3 sentences, describe how you would "Print all the odd numbers from 0 to x",...
In 1-3 sentences, describe how you would "Print all the odd numbers from 0 to x", Recursively using C++
Write an algorithm not code or solution only algorithm such as (step1, step2.....about. 1.How would you...
Write an algorithm not code or solution only algorithm such as (step1, step2.....about. 1.How would you use a stack to verify whether a given string is a palindrome or not. 2. How would you check if a string is a palindrome or not, using queues and deques.
Create a function in MIPS using MARS to determine whether a user input string is a...
Create a function in MIPS using MARS to determine whether a user input string is a palindrome or not. Assume that the function is not part of the same program that is calling it. This means it would not have access to your .data segment in the function, so you need to send and receive information from the function itself. The program should be as simple as possible while still using necessary procedures. Follow the instructions below carefully. Instructions: ●...
Describe in one or two sentences how (not what you would do if you knew the...
Describe in one or two sentences how (not what you would do if you knew the identity of the solution) you could experimentally identify the contents of a test tube containing one of the following two solutions using a common aqueous test solution: pb(no3)2 or kno3
This is for C++ A string is a palindrome if reverse of the string is same...
This is for C++ A string is a palindrome if reverse of the string is same as the original string. For example, “abba” is palindrome, but “abbc” is not palindrome. Basically a string with a plane of symmetry in the middle of it is considered a palindrome. For example, the following strings are palindromic: "abbbbba", "abba", "abbcbba", "a", etc. For this problem, you have an input string consisting of both lowercase or uppercase characters. You are allowed to pick and...
How would you check if a string is a palindrome or not, using queues and deques.
How would you check if a string is a palindrome or not, using queues and deques.
In five sentences describe the following: a) how you would implement a stack using an array,...
In five sentences describe the following: a) how you would implement a stack using an array, including the push and pop operation b) how you could implement a queue using a linked list, including what type of linked list would be best, the enqueue and dequeue operations
Using c++ Valid Palindrome In this assignment, you need to implement a bool isPalindrome(string s) function....
Using c++ Valid Palindrome In this assignment, you need to implement a bool isPalindrome(string s) function. Given a string s, isPalindrome(s) can determine if s is a palindrome, considering only alphanumeric characters and ignoring cases. Note: for the purpose of this problem, we define empty string as valid palindrome. Example 1: Input: ”A man, a plan, a canal: Panama” Output: true Example 2: Input: ”race a car” Output: false Requirement: There are many methods to check if a string is...
In a few sentences, describe a possible study that would require you to use a chi-square...
In a few sentences, describe a possible study that would require you to use a chi-square analysis. Be sure to describe what your variable(s) are, how they were measured (being sure to mention the scale of measurement), and what hypothesis you would be testing.
1. MAKE A SOLUTION PROBLEM a) Starting with solid sucrose, C12H22O11, describe how you would prepare...
1. MAKE A SOLUTION PROBLEM a) Starting with solid sucrose, C12H22O11, describe how you would prepare 250.0 mL of 0.250 M sucrose solution. Make sure your work supports your answer. b) Describe how you would prepare 350.0 mL of 0.100 M C12H22O11 starting with 3.00 L of 1.50 M C12H22O11. Make sure your work supports your answer. 2. MAKE A SOLUTION PROBLEM a) How would you prepare 250.0 mL of 0.150 M AgNO3 solution starting with pure AgNO3? Make sure...