Question

need this urgent please thank you very much

1.4 A sequence is a palindrome if it reads the same backward as forward. For example, the string rammar is a palindrome. The function palindrome (1st) returns true if 1st is a palindrome, and false otherwise. Complete the definition. template <typename T> bool palindrome (onst isT 1st)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

template<typename T>
bool palindrome(const list<T> &lst) {

int i = 0, j = lst.size()-1;

while (i < j ) {

if(lst[i] != lst[j])
return false;

i = i + 1;
j = j - 1;


}

return true;


}



Thanks, PLEASE UPVOTE if helpful

Add a comment
Know the answer?
Add Answer to:
need this urgent please thank you very much 1.4 A sequence is a palindrome if it...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • palindrome is a string that reads the same both forward and backward. C++ For example, the...

    palindrome is a string that reads the same both forward and backward. C++ For example, the string "madam" is a palindrome. Write a program that uses a recursive function to check whether a string is a palindrome. Your program must contain a value-returning recursive function that returns true if the string is a palindrome and false otherwise. Do not use any global variables; use the appropriate parameters.

  • A palindrome is a word, phrase, number, or other sequence of characters which reads the same...

    A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward as forward, such as madam or racecar. Write a recursive method in java that accepts a integer as its argument and returns true if it is palindrome, false otherwise. public class Recursion {                 public static void main(String[] args) {                                 Recursion r = new Recursion();                                 System.out.println(“Is 12321 a palindrome? “+ra.isPalindrome(12321)); //true                 }                 public Boolean isPalindrome(int num){                                 return false;...

  • Palindrome Detector A palindrome is any word, phase, or sentences that reads the same forward and...

    Palindrome Detector A palindrome is any word, phase, or sentences that reads the same forward and backward. Here are some well-know palindrome. Write a bool function that uses recursion to determine if a string arguments is a palindrome. The function should return true if the argument reads the same forward and backward. Demonstrate the function in a program

  • A palindrome is a word that is spelled the same forward and backward. For example, rotor...

    A palindrome is a word that is spelled the same forward and backward. For example, rotor and redder are palindromes, but motor is not. Write a recursive function that takes a word (string) and check if it is palindrome or not (The function should return True if the word is palindrome otherwise it should return False). USING PYTHON

  • Implement a function that returns true if a String is Palindrome or false otherwise. A Palindrome...

    Implement a function that returns true if a String is Palindrome or false otherwise. A Palindrome is a String that reads from right and left the same. An empty String, and a String with one character are Palindrome. public static boolean isPalindrome (String str) {

  • This is a java question A palindrome is a word or phrase that reads the same...

    This is a java question A palindrome is a word or phrase that reads the same forward and backward, ignoring blanks and punctuations, and considering uppercase and lowercase versions of the same letter to be equal. For example, the following are palindromes: warts n straw radar Able was I ere I saw Elba tacocat Write a program named Palindrome.java that will accept a file (file name) from the command argument list and decide whether each line in the file is...

  • Write a function check palindrome, which takes a string x as argument and which returns True...

    Write a function check palindrome, which takes a string x as argument and which returns True if x is a palindrome, and False otherwise. A palindrome is a word that reads the same backwards as forwards (like for example “racecar”). Your function should be recursive (i.e. call itself) and proceed as follows. 1. If x is a string of length 0 or 1 return True. 2. If the rst and the last letter of x are di erent, return False....

  • answer in c++ please , Your objective is to write the definition of the function Equal()...

    answer in c++ please , Your objective is to write the definition of the function Equal() whose header is template <typename T> bool Equal(Node<T>* ar1,Node<T>* ar2) It returns true if the nodes of ar1 and ar2 with the same position have the same value, and ar1 and ar2 have the same length; otherwise, it returns false.

  • Stack help. I need help with my lab assignment. Complete a method for a class named...

    Stack help. I need help with my lab assignment. Complete a method for a class named Palindrome that evaluates a string phrase to determine if the phrase is a palindrome or not. A palindrome is a sequence of characters that reads the same both forward and backward. When comparing the phrase to the same phrase with the characters in reverse order, an uppercase character is considered equivalent to the same character in lowercase, and spaces and punctuation are ignored. The...

  • please explain the answer A sequence of characters is called a palindrome if it reads the...

    please explain the answer A sequence of characters is called a palindrome if it reads the same way forward or backward. For example, 59AA95 is a six-character palindrome, and 59A95 is a five-character palindrome. Some other instances of palindromes: U NU, LON NOL, MALAYALAM, NOW ON, PUT UP, TOO HOT TO HOOT, NEVER ODD OR EVEN, ABLE WAS I ERE I SAW ELBA, and POOR DAN IS IN A DROOP. Find the number of nine-character palindromes that can be formed...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT