| View previous topic :: View next topic |
| Author |
Message |
Matt Guest
|
Posted: Sun Sep 28, 2003 6:23 pm Post subject: 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.
|
|
| Back to top |
|
 |
Ivan Vecerina Guest
|
Posted: Sun Sep 28, 2003 7:00 pm Post subject: Re: reverse the order of the words |
|
|
"Matt" <jrefactors (AT) hotmail (DOT) com> wrote
| Quote: | 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.
|
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,
--
http://ivan.vecerina.com
|
|
| Back to top |
|
 |
Mike Wahler Guest
|
Posted: Sun Sep 28, 2003 9:11 pm Post subject: Re: reverse the order of the words |
|
|
"Matt" <jrefactors (AT) hotmail (DOT) com> wrote
| Quote: | 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.
|
here homework do not do We.
this read Please:
http://www.slack.net/~shiva/welcome.txt
you Thank,
-Mike
|
|
| Back to top |
|
 |
Kevin Goodsell Guest
|
Posted: Sun Sep 28, 2003 9:12 pm Post subject: Re: reverse the order of the words |
|
|
Mike Wahler wrote:
| Quote: | "Matt" <jrefactors (AT) hotmail (DOT) com> wrote in message
news:ba8a039e.0309281023.1e42ed9 (AT) posting (DOT) google.com...
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.
here homework do not do We.
this read Please:
http://www.slack.net/~shiva/welcome.txt
|
Or even this:
http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.2
-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.
|
|
| Back to top |
|
 |
Ron Natalie Guest
|
Posted: Mon Sep 29, 2003 2:15 pm Post subject: Re: reverse the order of the words |
|
|
"Mike Wahler" <mkwahler (AT) mkwahler (DOT) net> wrote
| Quote: | "Matt" <jrefactors (AT) hotmail (DOT) com> wrote in message
news:ba8a039e.0309281023.1e42ed9 (AT) posting (DOT) google.com...
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.
here homework do not do We.
You sound like Master Yoda when you talk like that  |
|
|
| Back to top |
|
 |
David Rubin Guest
|
Posted: Mon Sep 29, 2003 6:08 pm Post subject: Re: reverse the order of the words |
|
|
Ron Natalie wrote:
| Quote: |
"Mike Wahler" <mkwahler (AT) mkwahler (DOT) net> wrote
"Matt" <jrefactors (AT) hotmail (DOT) com> wrote in message
news:ba8a039e.0309281023.1e42ed9 (AT) posting (DOT) google.com...
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.
here homework do not do We.
You sound like Master Yoda when you talk like that
|
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
|
|
| Back to top |
|
 |
Mike Wahler Guest
|
Posted: Mon Sep 29, 2003 6:41 pm Post subject: Re: [OT] reverse the order of the words |
|
|
"Ron Natalie" <ron (AT) sensor (DOT) com> wrote
| Quote: |
"Mike Wahler" <mkwahler (AT) mkwahler (DOT) net> wrote
"Matt" <jrefactors (AT) hotmail (DOT) com> wrote in message
news:ba8a039e.0309281023.1e42ed9 (AT) posting (DOT) google.com...
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.
here homework do not do We.
You sound like Master Yoda when you talk like that
|
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
|
|
| Back to top |
|
 |
Ron Natalie Guest
|
Posted: Mon Sep 29, 2003 6:48 pm Post subject: Re: [OT] reverse the order of the words |
|
|
"Mike Wahler" <mkwahler (AT) mkwahler (DOT) net> wrote
| Quote: | here homework do not do We.
You sound like Master Yoda when you talk like that :-)
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?
|
Not necessarily backwards, but many of his phrasing is reordered
to make him seem more alien.
|
|
| Back to top |
|
 |
WW Guest
|
Posted: Mon Sep 29, 2003 6:50 pm Post subject: Re: [OT] reverse the order of the words |
|
|
Mike Wahler wrote:
| Quote: | here homework do not do We.
You sound like Master Yoda when you talk like that :-)
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?
|
I backwards did not talk, my apprentice. ;-)
--
WW aka Attila
|
|
| Back to top |
|
 |
|