Friday, 11 October 2013

Check Palindrome using double link list

Palindrome  is A palindrome is a word, phrase, number, or other sequence of symbols or elements, whose meaning may be interpreted the same way in either forward or reverse direction.(wiki answer).
Two check given string is palindrome or not.It is very easy if we use double link list.

Procedure :-

::-  insert each char of string in double link list with each node contain only one char.

::- intialise "HEAD" to first node & "TELL" to last node.

::- check data at first node & last node then increment head & decrement in tell than check     again untill any mismatch found or they reaches to mid of list


;;- IF all are match than it is successful condition else unsuccessful

                                  C program :-



 //palindrome;  
 //if you found spelling mistake anywhere please ignore  
 #include<stdio.h>  
 #include<stdlib.h>  
 #include<malloc.h>  
 #include<string.h>  
 int create(char);  
 int check(int);  
 struct node  
 {  
      char c;  
      struct node *fro;  
      struct node *back;  
 }*head=NULL,*tell=NULL; // to pointer head point to first node & tell point to last node   
             //initialy list is empty so head=tell=NULL  
 typedef struct node node;  
 main()  
 {  
      char arr[20];  
      int m,i;  
      printf("\n enter string to check :");  
      scanf("%s",&arr);  
      m=strlen(arr);    // calculating lenghth of string  
      printf("\n length of string is %d",m);  
      for(i=0;i<m;i++)  
      {  
           create(arr[i]); // creating a double ling list with each node containning a single char  
      }  
      display();  
      check(m);   
 }   
 create(char ch) // creating double link list  
 {  
      node *temp,*r;  
      temp=head;  
      r=(node*)malloc(sizeof(node));  // allocating space node dynamicaly  
      r->c=ch;  
      if(head == NULL)  
      {  
           head=r;  
           tell=r;  
           head->fro=NULL;  
           head->back=NULL;  
      }  
      else  
      {  
           tell->fro=r;  
           r->back=tell;  
           tell=tell->fro;  
           tell->fro=NULL;  
      }  
 }  
 display()  
 {  
      node *temp;  
      temp=head;  
      printf("\n\n\t");  
      while(temp != NULL) // traverse list & print volue  
      {  
           printf("%c",temp->c);  
           temp=temp->fro;  
      }  
 }  
 check(int m) // funtion check our requrement  
 {  
      node *tf,*tt;  
      tf=head;  
      tt=tell;  
      while(m/2 > 0)   
      {  
           if(tf->c == tt->c)  
           {  
                tf=tf->fro;  
                tt=tt->back;  
           }  
           else  
           {  
           printf("\n\n\t not a palidrome :???");  
           exit(0);  
        }  
        m--;  
      }  
      printf("\n\n\t it is palidrome !!!!");  
 }  

OUTPUT :-


42 comments:

  1. You have made some really good points there. I checked on the web
    to find out more about the issue and found most people will go along with your views on this web site.


    Feel free to visit my page ... Christian Louboutin Boots

    ReplyDelete
  2. Greate post. Keep posting such kind of information on your
    page. Im really impressed by it.
    Hello there, You have performed an incredible job.

    I will certainly digg it and personally suggest to my friends.
    I'm confident they will be benefited from this site.

    My homepage propane cylinder sizes chart

    ReplyDelete
  3. Superb post however I was wondering if you could write a litte more on this topic?
    I'd be very grateful if you could elaborate a little bit more.
    Thank you!

    Look at my web blog: Vietnam tours

    ReplyDelete
  4. Having read this I believed it was very enlightening.
    I appreciate you spending some time and energy to put this informative article together.
    I once again find myself spending way too much time both reading
    and leaving comments. But so what, it was still worthwhile!


    Stop by my web page Louis Vuitton Online

    ReplyDelete
  5. Thanks very interesting blog!

    Also visit my web-site; Louboutin Shoes

    ReplyDelete
  6. I visit each day a few blogs and information sites to read posts, however
    this website offers quality based content.

    My blog Christian Louboutin Outlet

    ReplyDelete
  7. What's up, after reading this awesome post i am as well happy to share my know-how here with colleagues.


    my web blog - Louboutin Shoes

    ReplyDelete
  8. I do not even know the way I finished up here,
    however I thought this publish was once great.
    I do not know who you're however definitely you're going to a well-known blogger in the event you aren't already.

    Cheers!

    my website - Christian Louboutin Heels

    ReplyDelete
  9. I enjoy what you guys tend to be up too. This sort of clever work and reporting!
    Keep up the wonderful works guys I've included you guys to our blogroll.


    Here is my site - Christian Louboutin Pumps

    ReplyDelete
  10. I absolutely love your website.. Pleasant colors & theme.
    Did you build this site yourself? Please reply back as I'm looking to create my very own site and want to find out where you got this from or exactly
    what the theme is named. Kudos!

    Here is my web page: Christian Louboutin Boots

    ReplyDelete
  11. First off I would like to say great blog! I had a quick
    question that I'd like to ask if you do not mind. I was curious to find out how you center yourself and
    clear your head prior to writing. I have had a hard time clearing my thoughts in getting my
    ideas out there. I do enjoy writing but it just seems like the first
    10 to 15 minutes tend to be wasted just trying to figure out
    how to begin. Any ideas or hints? Many thanks!


    Also visit my site ... Louis Vuitton Cheap

    ReplyDelete
  12. I am in fact thankful to the owner of this web page who has shared this enormous article at here.



    My website ... Louis Vuitton Outlet Store

    ReplyDelete
  13. whoah this blog is fantastic i love reading your
    posts. Stay up the good work! You know, lots of individuals are hunting around for this information, you can aid them greatly.


    Also visit my site - Louis Vuitton Handbags

    ReplyDelete
  14. This info is worth everyone's attention. Where can I find
    out more?

    Also visit my site ... Replica Louis Vuitton

    ReplyDelete
  15. I am truly pleased to glance at this blog posts which carries tons of valuable facts, thanks
    for providing these data.

    my homepage: Louis Vuitton Cheap

    ReplyDelete
  16. Hi there to all, it's truly a fastidious for me to pay a visit
    this site, it consists of priceless Information.

    Here is my homepage Louis Vuitton Outlet Store

    ReplyDelete
  17. whoah this weblog is excellent i really like reading your articles.
    Stay up the great work! You recognize, lots of persons are hunting around for this
    information, you can help them greatly.

    My web-site: Beats By Dre Solo

    ReplyDelete
  18. Hello just wanted to give you a quick heads up.
    The text in your content seem to be running off the screen in Ie.
    I'm not sure if this is a formatting issue or something to do with web browser compatibility
    but I thought I'd post to let you know. The layout look great
    though! Hope you get the problem resolved soon. Cheers

    Also visit my web page - Louis Vuitton Online

    ReplyDelete
  19. Your way of explaining the whole thing in this article is actually pleasant,
    every one be capable of without difficulty be aware of it, Thanks a lot.


    my web page - Fake Louis Vuitton Bags

    ReplyDelete
  20. I was pretty pleased to uncover this page. I need to to thank you for your time for this particularly wonderful read!!
    I definitely enjoyed every bit of it and I have you book-marked
    to see new stuff on your web site.

    my web site; Christian Louboutin Heels

    ReplyDelete
  21. Thanks for sharing your thoughts about pelf. Regards

    Feel free to surf to my site Louboutin Shoes

    ReplyDelete
  22. Fine way of explaining, and good post to take data about my presentation topic, which i am going to deliver in institution of higher
    education.

    Also visit my web blog ... Christian Louboutin Outlet

    ReplyDelete
  23. First off I want to say wonderful blog! I had a quick question that I'd like to ask
    if you don't mind. I was interested to find out how you center yourself and clear your mind prior to writing.
    I've had a hard time clearing my thoughts in getting my ideas out there.
    I truly do enjoy writing but it just seems like the first 10 to 15
    minutes tend to be lost simply just trying to figure out how to
    begin. Any suggestions or hints? Cheers!

    my web page :: Christian Louboutin Shoes

    ReplyDelete
  24. Hey there, You have done an excellent job. I'll definitely digg it and personally suggest to my friends.
    I'm sure they will be benefited from this website.

    Feel free to surf to my weblog - Christian Louboutin Outlet

    ReplyDelete
  25. What a information of un-ambiguity and preserveness of precious knowledge regarding unpredicted emotions.


    My blog ... christian Louboutin heels

    ReplyDelete
  26. Hello! Quick question that's totally off topic.
    Do you know how to make your site mobile friendly?
    My website looks weird when viewing from my iphone 4.
    I'm trying to find a template or plugin that might be able to fix this problem.

    If you have any recommendations, please share. Appreciate
    it!

    Take a look at my web blog; Christian Louboutin Replica

    ReplyDelete
  27. I blog frequently and I truly appreciate your information. This great article
    has truly peaked my interest. I am going to book mark your blog and
    keep checking for new information about once a week.
    I subscribed to your RSS feed as well.

    my homepage: Christian Louboutin Boots

    ReplyDelete
  28. Great article, totally what I was looking for.


    my website - Christian Louboutin Boots

    ReplyDelete
  29. Appreciate this post. Will try it out.

    my page: Christian Louboutin Shoes

    ReplyDelete
  30. Every weekend i used to pay a quick visit this web page, for the reason that i want enjoyment, since this this web site
    conations genuinely fastidious funny data too.


    my web site ... Christian Louboutin Pumps

    ReplyDelete
  31. Good day I am so grateful I found your site,
    I really found you by accident, while I was browsing on Aol for something else, Nonetheless I am here now
    and would just like to say thanks a lot for a remarkable post and a all round exciting blog (I also love the
    theme/design), I don't have time to read through it all at the moment but I
    have bookmarked it and also included your RSS feeds, so when I have time
    I will be back to read more, Please do keep up
    the excellent work.

    My homepage: Christian Louboutin Heels

    ReplyDelete
  32. Definitely imagine that that you stated. Your favorite justification appeared to be at
    the web the simplest factor to be mindful of.
    I say to you, I definitely get irked whilst other people consider worries that they plainly do not know
    about. You managed to hit the nail upon the highest and
    outlined out the whole thing without having side effect ,
    people could take a signal. Will probably be again to get more.
    Thank you

    my page - Replica New Balance

    ReplyDelete
  33. Yesterday, while I was at work, my cousin stole my apple ipad
    and tested to see if it can survive a thirty foot drop,
    just so she can be a youtube sensation. My iPad is now destroyed and she has 83
    views. I know this is entirely off topic but I had to share it with someone!



    Also visit my blog post ... Cheap Dr Dre Beats

    ReplyDelete
  34. You can definitely see your skills in the article you write.
    The arena hopes for more passionate writers such as
    you who are not afraid to say how they believe. Always go after your heart.


    My webpage; Replica Christian Louboutin

    ReplyDelete
  35. I'm not sure why but this weblog is loading very
    slow for me. Is anyone else having this problem or is it a issue on my end?
    I'll check back later and see if the problem still exists.


    Feel free to surf to my blog post Beats Headphones

    ReplyDelete
  36. Oh my goodness! Awesome article dude! Thank you so much, However I am encountering
    issues with your RSS. I don't understand the reason why I cannot join it.
    Is there anyone else getting similar RSS issues? Anyone that knows the answer
    can you kindly respond? Thanks!!

    Also visit my web site; Louis Vuitton Replica

    ReplyDelete
  37. What's Happening i'm new to this, I stumbled upon this I've discovered
    It absolutely helpful and it has aided me out loads.

    I am hoping to give a contribution & aid different users like its aided me.
    Great job.

    Look at my web blog - Dr Dre Headphones

    ReplyDelete
  38. My brother suggested I may like this website.
    He used to be entirely right. This put up truly made my day.
    You can not believe just how a lot time I had spent for this info!

    Thank you!

    Review my site: Christian Louboutin Replica

    ReplyDelete
  39. Incredible! This blog looks exactly like my old one!
    It's on a entirely different subject but it has pretty much the same
    layout and design. Wonderful choice of colors!

    Feel free to surf to my web-site - Louis Vuitton Bags

    ReplyDelete
  40. I love your blog page and your strategy - iit is genuinely cool to know there's more individuals out there which express exactly the same concepts.


    Also visit my webpage; eliquid

    ReplyDelete
  41. Greetings, There's no doubt that your website may be having internet browser compatibility issues.
    Whenever I look at your blog in Safari, it looks fine
    but when opening in I.E., it has some overlapping issues. I just wanted to give
    you a quick heads up! Besides that, fantastic website!


    Also visit my homepage; flat screen tv (youtube.com)

    ReplyDelete
  42. This is really a useful blog!! Thank you!

    ReplyDelete

THANKS FOR UR GREAT COMMENT

Blogger Widgets