Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1.8. Each of the following two procedures is intended to check whether a string is a palindrome (that is, reads the same forward and backward,

image text in transcribed

1.8. Each of the following two procedures is intended to check whether a string is a palindrome (that is, reads the same forward and backward, like pop and nursesrun). Each procedure takes a string as input and should output true if the input string is a palindrome and false otherwise. procedure check 1(a1,,an : string) answer := true for i=1 to n/2 if ai=an+1i then answer := false return answer procedure check 2(a1,,an: string ) answer := true for i=1 to n if ai=an+1i then answer := false return answer In both procedures, a1,a2, etc., refer to the individual characters of the string. For example, in the string wow, a1 is 'w', a2 is 'o', and a3 is 'w'. (a) (True/False) check1 is correct (outputs the correct answer). (b) (True/False) check2 is correct. (c) check 1 performs comparisons (answer in terms of n, the string length). (d) check 2 performs comparisons. (e) (True/False) check 1 takes longer to complete than check 2

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

Fundamentals Of Database System

Authors: Elmasri Ramez And Navathe Shamkant

7th Edition

978-9332582705

More Books

Students also viewed these Databases questions