Show Buttons
Share On Facebook
Share On Twitter
Share On Google Plus
Share On Linkdin
Share On Pinterest
Share On Reddit
Share On Stumbleupon
Contact us
Hide Buttons

Find Whether Given String is palindrome or Not.

Objec­tive : Write an algo­rithm to find Whether Given String is palin­drome or Not.

Input:  A String,

Out­put: true or false on whether string is palin­drome or not


  • Use recur­sive approach
  • Com­pare first and last char­ac­ters if they are not same– return false
  • If they are same make, remove the first and last char­ac­ters and make a recur­sive call. 


Jain niaJ => compare ‘J’ with ‘J’ =>returns true

ain nia => compare ‘a’ with ‘a’ =>returns true

in ni => compare ‘i’ with ‘i’ =>returns true

n n => compare ‘n’ with ‘n’ =>returns true

string length <2 => returns true

Com­plete Code:


Is Sumit Palindrome ??? :false
Is SumuS Palindrome ??? :true
Is ABCDEFGHGFEDCBA Palindrome ??? :true
Is Jain niaJ Palindrome ??? :true
Is SumuaS Palindrome ??? :false

You may also like...

  • Anony­mous

    This pro­gram is wrong. Try mod­i­fy­ing the sec­ond string to SumuaS and check. You will get the wrong result.

    • Sumit Jain

      Thanks for point­ing it out…I have cor­rected it.

  • kaos

    What if the String con­tains cap­i­tal let­ters and small let­ters in between? Exam­ple Nitin . It should return true right?