How many bit strings of length n are palindromes? Hint: Consider two cases n is even and n is odd. Note a palindrome is a "string" of letters or numbers which read the same frontwards and backwards. Examples: MOM, 1101011, 10111101 are palindromes.© BrainMass Inc. brainmass.com October 25, 2018, 5:36 am ad1c9bdddf
Hello and thank you for posting your question to BrainMass.
Let's see first how many different strings we can make with k bits.
If we have one bit, then we have two possible strings (namely "0" and "1")
If we have k=2 bits, then we have to possibilities for the first bit and two possibilities for the second bit, so together there are 2x2 = 4 possibles strings.
In a k length string, each bit has two possible values, hence the total number of strings is 2x2x.....2 = 2^k
Now we can start with out palindrome strings of length n.
Say we set the k<n bit. Then, by the definition of the palindrome this immediately sets the ...
String bits and palindromes are assessed in this solution.
Java: Palindrome Using BufferedReader
Write a program that reads in strings of characters and determines if each string is a palindrome. Each string appears on a separate input line. Echo-print each string, followed by " Is a palindrome" if the string is a palindrome or "Is not a palindrome" if the stringis not a palindrome. For example, given the input string Able was, I ere I saw Elba. The program should print "Is a palindrome." In detemining whether a string is a palindrome, consider uppercase and lower case letters to be the same and ignore punctuation characters and spares. The input file that you will be reading palindromes from is called "pals.txt". Look for methods like replace (), to lowerCase, to UpperCase,..etc. Write the output ( the string and if is a palindrome) to a file called "palsout.txt". Each line of text in the file pals.txt will contain a palindrome to test for. You can only use the BufferedReader class and not the Scanner class. Please examine the attachment, this is as far as I got, however I am able to compile but when executing I get and error. Please select palindrome files to save in the pals.txt file.View Full Posting Details