Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Complete the code (specifically the last 6 codes) to get the result which is down below. USING VISUAL MACHINE #include #include #include PowerString.h // initialize
Complete the code (specifically the last 6 codes) to get the result which is down below. USING VISUAL MACHINE #include #include #include "PowerString.h" // initialize str with ini_str passing as a parameter PowerString::PowerString(string ini_str) { str = ini_str; // return the current value of the private data member: str string PowerString::getString() const =0; i--) { result= result + str[i]; } return result; } // return a reverse string // using recursion to implement 17 Note that the private data member named str, has not been changed -- INSERT 12,2 // return a reverse string 11 using recursion to implement // Note that the private data member named str, has not been changed string PowerString: :rev_recursive) const { if (str.length() ==0) return str; string shorter =str. substr(i, str.length()-1); PowerString somePS (shorter); return (somePS. rev_recursive()+ str[o]); } // return a reverse string // using a stack to implement // Note that the private data member named str, has not been changed string PowerString:: rev_stack() const // return true if str is a palindrome // otherwise return false II A palindrome is defined as a sequence of characters which reads the same backward as forward // calling member function to implement 11 Note that the private data member named str, has not been changed bool PowerString::isPalindrome) const } // return true if str is a palindrome // otherwise return false A palindrome is defined as a sequence of characters which reads the same backward as forward // using recursion to implement // Note that the private data member named str, has not been changed bool PowerString::isPalindrome_recursive) const { } 11 return a palindrome which contains str then followed by the reverse of str // calling member function to implement // Note that the private data member named str, has not been changed bool PowerString::isPalindrome) const { 11 return true if str is a palindrome // otherwise return false 11 A palindrome is defined as a sequence of characters which reads the same backward as forward // using recursion to implement // Note that the private data member named str, has not been changed bool PowerString::isPalindrome_recursive) const } // return a palindrome which contains str then followed by the reverse of str 11 for example, if str is "abc", it returns "abccba"; if str is "ab", it returns "abba", and so on. 11 return value is guaranteed to be a palindrome with even number of characters // Note that the private data member named str, has not been changed string PowerString:: evenPalindrome() const K } 11 return a palindrome which contains str then followed by the reverse of str without the last character of str 11 for example, if str is "abc", it returns "abcba"; if str is "ab", it returns "aba", and so on. // return value is guaranteed to be a palindrome with odd number of characters // Note that the private data member named str, has not been changed string PowerString :: oddPalindrome () const 11 displays str followed by a new line marker // to the standard output void PowerString::print() const } Is "A" a palindrome? true The palindrome with odd number of characters: A The palindrome with even number of characters: AA IS "A" a palindrome? true Is " AA a palindrome? true Please input a string to watch its magic: CS 216 The original string you type is: CS 216 Reverse of the string (using a loop): 612 SC Reverse of the string (using recursion): 612 SC Reverse of the string (using a stack): 612 SC Is " CS 216" a palindrome? false The palindrome with odd number of characters: CS 21612 Sc The palindrome with even number of characters: CS 216612 SC Is " CS 21612 SC " a palindrome? true Is " CS 216612 SC " a palindrome? true Please input a string to watch its magic: 02/10/2021 The original string you type is: 02/10/2021 Reverse of the string (using a loop): 1202/01/20 Reverse of the string (using recursion) : 1202/01/20 Reverse of the string (using a stack): 1202/01/20 Is " 02/10/2021 " a palindrome? false The palindrome with odd number of characters: 02/10/2021202/01/20 The palindrome with even number of characters: 02/10/20211202/01/20 IS" 02/10/2021202/01/20 a palindrome? true Is " 02/10/20211202/01/20" a palindrome? true Please input a string to watch its magic: race car The original string you type is: race car Reverse of the string (using a loop) : rac ecar Reverse of the string (using recursion): rac ecar Reverse of the string (using a stack) : rac ecar race car Is " a palindrome? false The palindrome with odd number of characters: race carac ecar race carracecar T! The palindrome with even number of characters: Is " race caracecar a palindrome? true Is race carracecar a palindrome? true IT Please input a string to watch its magic: racecar The original string you type is: racecar Reverse of the string (using a loop) : racecar Reverse of the string (using recursion): racecar Reverse of the string (using a stack): racecar Is " racecar a palindrome? true The palindrome with odd number of characters: racecaracecar The palindrome with even number of characters: racecarracecar Is " racecaracecar a palindrome? true Is racecarracecar " a palindrome? true Please input a string to watch its magic: noon The original string you type is: noon Reverse of the string (using a loop): noon Reverse of the string (using recursion) : noon Reverse of the string (using a stack): noon Is " noon a palindrome? true The palindrome with odd number of characters: noonoon The palindrome with even number of characters: noonnoon Is " noonoon a palindrome? true Is noonnoon a palindrome? true TI TI
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started