Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!