ANSWERS: 3
  • DYOH... I had to when I was in school! [EDIT] This is NOT psuedocode, but what you must code that way. Ok... You have the length of the array. Starting at the first character, compare it to the LAST letter. IF they are the same, compare character 2 to the last character minus 1. If THEY are the same, compare the third to the last minus 2. Continue until all characters have been checked and match, unless you have a character left over (the middle character). If all DO match, print it. If not, go to the next word in the list. This question is simple logic. I know if you're learning it's not that easy, but if you can't figure out how to figure it out, how will you do the more complicated ones?
  • palindromeTester(char[] testedArray){ //assuming array's are numbered from 0 int i =0; bool helperBool = true; //while the condition for being a palindrome is NOT UNsatisfied AND while you're not yet halfway through the array while(helperBool && i<(n-1)/2 ){ if(testedArray[i] == testedArray[n-1-i]){} //if the ith letter is equal to the n--1ith letter, do nothing (why n-1?) else{helperBool = false} //otherwise, indicate that this array is not a palindrome } }
  • That's easy, just compare the nth letter with the (length-n)th letter. You can figure out what to do for even/odd length words, and how much of it you have to compare (half the word, the whole word, et cetera)

Copyright 2023, Wired Ivy, LLC

Answerbag | Terms of Service | Privacy Policy