Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Problem 1 - Palindrome 1.1 The Problem: Determine whether a string is a palindrome . A palindrome is a string that is read the same
Problem 1 - Palindrome
1.1 The Problem:
Determine whether a string is a palindrome.
A palindrome is a string that is read the same from front-to-back and back-to-front.
Example: noon, racecar
There are several different approaches to solve this problem, known as algorithm.
An algorithm is a sequence of steps that accomplish a task.
1.2 Algorithms
Algorithm 1:
- Reverse the string
- Compare the reversed string to the original string.
- For example: reverse of string noon is also noon so noon is a palindrome, but the reverse of string dented is detned they are different and therefore dented is not a palindrome.
Algorithm 2:
- split the string into two halves (for odd number of length, omit the middle char)
- Reverse the second half
- Compare the first half to the reversed second half
Algorithm 3:
- Compare the first char to the last char of the string
- Compare the 22nd char to the 22nd last char
- Continue until the middle of the string is reached
Your Task: There might have other ways to solve this task, but you are supposed to write functions based on these three algorithms.
Python
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