467,147 Members | 1,234 Online

# 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" 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" 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" wrote in message news:ba*************************@posting.google.co m...Given an array of characters which form a sentence of words, give anefficient 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" wrote in message news:X7*****************@newsread3.news.pas.earthl ink.net... "Matt" 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" wrote in message news:X7*****************@newsread3.news.pas.earthl ink.net... "Matt" 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" wrote in message news:3f***********************@news.newshosting.co m... "Mike Wahler" wrote in message news:X7*****************@newsread3.news.pas.earthl ink.net... "Matt" 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" 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
 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.