467,147 Members | 1,234 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,147 developers. It's quick & easy.

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.
Jul 19 '05 #1
  • viewed: 7332
Share:
8 Replies
"Matt" <jr********@hotmail.com> wrote in message
news:ba*************************@posting.google.co m...
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

Jul 19 '05 #2
"Matt" <jr********@hotmail.com> wrote in message
news:ba*************************@posting.google.co m...
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

Jul 19 '05 #3
Mike Wahler wrote:
"Matt" <jr********@hotmail.com> wrote in message
news:ba*************************@posting.google.co m...
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-lit...t.html#faq-5.2

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

Jul 19 '05 #4

"Mike Wahler" <mk******@mkwahler.net> wrote in message news:X7*****************@newsread3.news.pas.earthl ink.net...
"Matt" <jr********@hotmail.com> wrote in message
news:ba*************************@posting.google.co m...
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 :-)
Jul 19 '05 #5
Ron Natalie wrote:

"Mike Wahler" <mk******@mkwahler.net> wrote in message news:X7*****************@newsread3.news.pas.earthl ink.net...
"Matt" <jr********@hotmail.com> wrote in message
news:ba*************************@posting.google.co m...
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
Jul 19 '05 #6

"Ron Natalie" <ro*@sensor.com> wrote in message
news:3f***********************@news.newshosting.co m...

"Mike Wahler" <mk******@mkwahler.net> wrote in message

news:X7*****************@newsread3.news.pas.earthl ink.net...
"Matt" <jr********@hotmail.com> wrote in message
news:ba*************************@posting.google.co m...
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
Jul 19 '05 #7

"Mike Wahler" <mk******@mkwahler.net> wrote in message news:q1*****************@newsread4.news.pas.earthl ink.net...
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.
Jul 19 '05 #8
WW
Mike Wahler wrote:
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
Jul 19 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

35 posts views Thread by Raymond Hettinger | last post: by
59 posts views Thread by Raymond Hettinger | last post: by
3 posts views Thread by R. Rajesh Jeba Anbiah | last post: by
14 posts views Thread by ford_desperado@yahoo.com | last post: by
10 posts views Thread by aatish19@gmail.com | last post: by
20 posts views Thread by mike7411@gmail.com | last post: by
40 posts views Thread by KG | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.