Re: Palindrome



John Smith wrote
(in article <LVMYg.146809$1T2.30093@pd7urf2no>):

tawsword wrote:
Hey Fellas, what's the pseudocode for a program to detect a word if
it's a palindrome or not, using linked lists?

c
Compare first letter with last letter, then 2nd letter with
penultimate letter, and so on. Continue this process until you
reach the middle. Here's a function in C that does it:

/* return a boolean value indicating
whether str is a palindrome */
int ispal(char *str)
{
int lo, hi, mid;

hi = strlen(str) - 1;
mid = hi / 2;
for(lo = 0; lo <= mid; lo++, hi--)
{
if(str[lo] != str[hi])
return 0;
}
return 1;
}

Why do you want to use a linked list?

Because the professor picked the wrong problem to use for a
linked list homework assignment?




--
Randy Howard (2reply remove FOOBAR)
"The power of accurate observation is called cynicism by those
who have not got it." - George Bernard Shaw





.



Relevant Pages

  • Re: Palindrome
    ... it's a palindrome or not, using linked lists? ... whether str is a palindrome */ ... int ispal ...
    (comp.programming)
  • Re: Palindrome
    ... using linked lists? ... I think the OP has a perfectly good reason for wanting to use a linked ... "palindrome code homework" does it for example. ... Can't you supply the direct link to ...
    (comp.programming)
  • Re: Palindrome
    ... Ben Pfaff wrote: ... using linked lists? ... I think the OP has a perfectly good reason for wanting to use a linked ... "palindrome code homework" does it for example. ...
    (comp.programming)
  • Re: Palindrome
    ... it's a palindrome or not, using linked lists? ... I don't think there's any good reason to use a linked list for ... --FreeVGA Attribute Controller Reference ...
    (comp.programming)
  • Re: Palindrome
    ... it's a palindrome or not, using linked lists? ... that Oadditional storage be used and the requirements that the ... casual observer. ...
    (comp.programming)