algorithm reversewords(value prevalue sb is string buffer postthe words in value have been reversed last value length start last while last > /skip whitespace while start > and value[startwhitespace start start end while last start /march down to the index before the beginning of the word while start > and start whitespace start start end while /append chars from start to length to string buffer sb for start to last sb append(value[ ] end for /if this isn' the last word in the string add some whitespace after the word in the buffer if start sb append(' end if last start start last end while /check if we have added one too many whitespace to sb if sb[sb length - whitespace /cut the whitespace sb length sb length - end if return sb end reversewords detecting palindrome although not frequent algorithm that will be applied in real-life scenarios detecting palindrome is funand as it turns out pretty trivial algorithm to design the algorithm that we present has (nrun time complexity our algorithm uses two pointers at opposite ends of string we are checking is palindrome or not these pointers march in towards each other always checking that each character they point to is the same with respect to value figure shows the ispalindrome algorithm in operation on the string "was it eliot' toilet saw?if you remove all punctuationand white space from the aforementioned string you will find that it is valid palindrome