reverse the order of the words

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Matt

    reverse the order of the words

    Given an array of characters which form a sentence of words, give an
    efficient algorithm to reverse the order of the words (not characters)
    in it.
  • Ivan Vecerina

    #2
    Re: reverse the order of the words

    "Matt" <jrefactors@hot mail.com> wrote in message
    news:ba8a039e.0 309281023.1e42e d9@posting.goog le.com...[color=blue]
    > Given an array of characters which form a sentence of words, give an
    > efficient algorithm to reverse the order of the words (not characters)
    > in it.[/color]

    Matt,
    You really are posting a series of classic interview/quizz questions
    in comp.lang.c* groups. Some kind of homework ?

    For this problem, a classic approach is to reverse the whole sentence,
    then reverse the characters of each word. This has the advantage of
    being easy to apply in-place.


    Cheers,
    --
    Ivan Vecerina - expert in medical devices, software - info, links, contact information, code snippets




    Comment

    • Mike Wahler

      #3
      Re: reverse the order of the words

      "Matt" <jrefactors@hot mail.com> wrote in message
      news:ba8a039e.0 309281023.1e42e d9@posting.goog le.com...[color=blue]
      > Given an array of characters which form a sentence of words, give an
      > efficient algorithm to reverse the order of the words (not characters)
      > in it.[/color]

      here homework do not do We.

      this read Please:


      you Thank,
      -Mike



      Comment

      • Kevin Goodsell

        #4
        Re: reverse the order of the words

        Mike Wahler wrote:
        [color=blue]
        > "Matt" <jrefactors@hot mail.com> wrote in message
        > news:ba8a039e.0 309281023.1e42e d9@posting.goog le.com...
        >[color=green]
        >>Given an array of characters which form a sentence of words, give an
        >>efficient algorithm to reverse the order of the words (not characters)
        >>in it.[/color]
        >
        >
        > here homework do not do We.
        >
        > this read Please:
        > http://www.slack.net/~shiva/welcome.txt
        >[/color]

        Or even this:



        -Kevin
        --
        My email address is valid, but changes periodically.
        To contact me please use the address from a recent posting.

        Comment

        • Ron Natalie

          #5
          Re: reverse the order of the words


          "Mike Wahler" <mkwahler@mkwah ler.net> wrote in message news:X7Idb.7917 $NX3.6757@newsr ead3.news.pas.e arthlink.net...[color=blue]
          > "Matt" <jrefactors@hot mail.com> wrote in message
          > news:ba8a039e.0 309281023.1e42e d9@posting.goog le.com...[color=green]
          > > Given an array of characters which form a sentence of words, give an
          > > efficient algorithm to reverse the order of the words (not characters)
          > > in it.[/color]
          >
          > here homework do not do We.
          >[/color]
          You sound like Master Yoda when you talk like that :-)


          Comment

          • David Rubin

            #6
            Re: reverse the order of the words

            Ron Natalie wrote:[color=blue]
            >
            > "Mike Wahler" <mkwahler@mkwah ler.net> wrote in message news:X7Idb.7917 $NX3.6757@newsr ead3.news.pas.e arthlink.net...[color=green]
            > > "Matt" <jrefactors@hot mail.com> wrote in message
            > > news:ba8a039e.0 309281023.1e42e d9@posting.goog le.com...[color=darkred]
            > > > Given an array of characters which form a sentence of words, give an
            > > > efficient algorithm to reverse the order of the words (not characters)
            > > > in it.[/color]
            > >
            > > here homework do not do We.
            > >[/color]
            > You sound like Master Yoda when you talk like that :-)[/color]

            Or a Boy Scout :-)

            /david

            --
            Andre, a simple peasant, had only one thing on his mind as he crept
            along the East wall: 'Andre, creep... Andre, creep... Andre, creep.'
            -- unknown

            Comment

            • Mike Wahler

              #7
              Re: [OT] reverse the order of the words


              "Ron Natalie" <ron@sensor.com > wrote in message
              news:3f783e69$0 $37004$9a6e19ea @news.newshosti ng.com...[color=blue]
              >
              > "Mike Wahler" <mkwahler@mkwah ler.net> wrote in message[/color]
              news:X7Idb.7917 $NX3.6757@newsr ead3.news.pas.e arthlink.net...[color=blue][color=green]
              > > "Matt" <jrefactors@hot mail.com> wrote in message
              > > news:ba8a039e.0 309281023.1e42e d9@posting.goog le.com...[color=darkred]
              > > > Given an array of characters which form a sentence of words, give an
              > > > efficient algorithm to reverse the order of the words (not characters)
              > > > in it.[/color]
              > >
              > > here homework do not do We.
              > >[/color]
              > You sound like Master Yoda when you talk like that :-)[/color]

              It may come as a surprise to many, but I've only seen
              the first Star Wars movie, but none of the sequels.
              Did this character speak backwards?

              -Mike


              Comment

              • Ron Natalie

                #8
                Re: [OT] reverse the order of the words


                "Mike Wahler" <mkwahler@mkwah ler.net> wrote in message news:q1%db.7944 $RW4.6693@newsr ead4.news.pas.e arthlink.net...
                [color=blue][color=green][color=darkred]
                > > > here homework do not do We.
                > > >[/color]
                > > You sound like Master Yoda when you talk like that :-)[/color]
                >
                > It may come as a surprise to many, but I've only seen
                > the first Star Wars movie, but none of the sequels.
                > Did this character speak backwards?[/color]

                Not necessarily backwards, but many of his phrasing is reordered
                to make him seem more alien.


                Comment

                • WW

                  #9
                  Re: [OT] reverse the order of the words

                  Mike Wahler wrote:[color=blue][color=green][color=darkred]
                  >>> here homework do not do We.
                  >>>[/color]
                  >> You sound like Master Yoda when you talk like that :-)[/color]
                  >
                  > It may come as a surprise to many, but I've only seen
                  > the first Star Wars movie, but none of the sequels.
                  > Did this character speak backwards?[/color]

                  I backwards did not talk, my apprentice. ;-)

                  --
                  WW aka Attila


                  Comment

                  Working...