Answered step by step
Verified Expert Solution
Link Copied!

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Flash XML Applications Use AS2 And AS3 To Create Photo Galleries Menus And Databases

Authors: Joachim Schnier

1st Edition

0240809173, 978-0240809175

More Books

Students also viewed these Databases questions

Question

What is the most important part of any HCM Project Map and why?

Answered: 1 week ago