By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,655 Members | 964 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,655 IT Pros & Developers. It's quick & easy.

Reverse a string "in place"

P: n/a
I've asked myself this question in the past but couldn't afford more
time to it (I program other languages for my bread and butter), so I'll
ask now since it's never too late.

What does the qualifier "in place" mean here? Does that mean without
using additional memory?

Dec 23 '05 #1
Share this Question
Share on Google+
10 Replies


P: n/a
Water Cooler v2 said:
I've asked myself this question in the past but couldn't afford more
time to it (I program other languages for my bread and butter), so I'll
ask now since it's never too late.

What does the qualifier "in place" mean here? Does that mean without
using additional memory?


What does the qualifier "in place" mean here?
?hat does the qualifier "in place" mean hereW
?eat does the qualifier "in place" mean herhW
?ert does the qualifier "in place" mean heahW
?ere does the qualifier "in place" mean teahW
?ere does the qualifier "in place" mean teahW
?ere noes the qualifier "in place" mead teahW
?ere naes the qualifier "in place" meod teahW
?ere naes the qualifier "in place" meod teahW
?ere naem the qualifier "in place" seod teahW
?ere naem the qualifier "in place" seod teahW
?ere naem "he qualifier "in placet seod teahW
Dec 23 '05 #2

P: n/a
Richard Heathfield wrote:
Water Cooler v2 said:

I've asked myself this question in the past but couldn't afford more
time to it (I program other languages for my bread and butter), so I'll
ask now since it's never too late.

What does the qualifier "in place" mean here? Does that mean without
using additional memory?

What does the qualifier "in place" mean here?
?hat does the qualifier "in place" mean hereW
?eat does the qualifier "in place" mean herhW
?ert does the qualifier "in place" mean heahW
?ere does the qualifier "in place" mean teahW
?ere does the qualifier "in place" mean teahW
?ere noes the qualifier "in place" mead teahW
?ere naes the qualifier "in place" meod teahW
?ere naes the qualifier "in place" meod teahW
?ere naem the qualifier "in place" seod teahW
?ere naem the qualifier "in place" seod teahW
?ere naem "he qualifier "in placet seod teahW
.
.
.

I hope you can see how this is going.

Badly. Whaet? :-)

S.
Dec 23 '05 #3

P: n/a
Skarmander said:
Richard Heathfield wrote:
?ere naem "he qualifier "in placet seod teahW
.
.
.

I hope you can see how this is going.

Badly. Whaet? :-)


I *knew* I should have written code to do that. (sigh)

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Dec 23 '05 #4

P: n/a
Cool! Thanks a bunch, Richard.

Dec 23 '05 #5

P: n/a
Richard Heathfield <in*****@invalid.invalid> wrote:
Skarmander said:
Richard Heathfield wrote:
?ere naem "he qualifier "in placet seod teahW
.
.
.

I hope you can see how this is going.

Badly. Whaet? :-)


I *knew* I should have written code to do that. (sigh)


Yeah, every Anglo-Saxon fule noes that that should be "Hwaet!".

Richard
Dec 23 '05 #6

P: n/a
Water Cooler v2 wrote:

I've asked myself this question in the past but couldn't afford
more time to it (I program other languages for my bread and
butter), so I'll ask now since it's never too late.

What does the qualifier "in place" mean here? Does that mean
without using additional memory?


Almost. It means returning the result in the same storage in which
it arrived. This doesn't prevent using temporary auxiliary memory.

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>
Dec 23 '05 #7

P: n/a

Chuck F. wrote:
Water Cooler v2 wrote:

I've asked myself this question in the past but couldn't afford
more time to it (I program other languages for my bread and
butter), so I'll ask now since it's never too late.

What does the qualifier "in place" mean here? Does that mean
without using additional memory?


Almost. It means returning the result in the same storage in which
it arrived. This doesn't prevent using temporary auxiliary memory.


Is there even a way you could do it without temporary memory? I can't
think of one.

Dec 23 '05 #8

P: n/a
On 2005-12-23, gooch <go******@comcast.net> wrote:

Chuck F. wrote:
Water Cooler v2 wrote:
>
> I've asked myself this question in the past but couldn't afford
> more time to it (I program other languages for my bread and
> butter), so I'll ask now since it's never too late.
>
> What does the qualifier "in place" mean here? Does that mean
> without using additional memory?


Almost. It means returning the result in the same storage in which
it arrived. This doesn't prevent using temporary auxiliary memory.


Is there even a way you could do it without temporary memory? I can't
think of one.


You could use the xor trick.
Dec 23 '05 #9

P: n/a
"Chuck F. " <cb********@yahoo.com> wrote in message
news:pY******************************@maineline.ne t...
Water Cooler v2 wrote:
I've asked myself this question in the past but couldn't afford
more time to it (I program other languages for my bread and
butter), so I'll ask now since it's never too late.

What does the qualifier "in place" mean here? Does that mean
without using additional memory?


Almost. It means returning the result in the same storage in which
it arrived. This doesn't prevent using temporary auxiliary memory.


But "in place" is usually taken to mean "with *constant* additional memory",
ie the amount of "temporary auxialliary memory" cannot depend on the length
of the string.

Alex
Dec 23 '05 #10

P: n/a
gooch wrote:
Chuck F. wrote:
Water Cooler v2 wrote:

I've asked myself this question in the past but couldn't
afford more time to it (I program other languages for my
bread and butter), so I'll ask now since it's never too
late.

What does the qualifier "in place" mean here? Does that mean
without using additional memory?


Almost. It means returning the result in the same storage in
which it arrived. This doesn't prevent using temporary
auxiliary memory.


Is there even a way you could do it without temporary memory? I
can't think of one.


Yes. It depends on the fact that a C string cannot contain '\0'.
It is not recommended. The implementation is left as an exercise.

(BTW, this does not eliminate the need for counters, etc.)

--
Some informative links:
news:news.announce.newusers
http://www.geocities.com/nnqweb/
http://www.catb.org/~esr/faqs/smart-questions.html
http://www.caliburn.nl/topposting.html
http://www.netmeister.org/news/learn2quote.html

Dec 23 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.