Do it in place. What does that mean?

This is a common expression for programmers and I’ll explain what it means and what the alternatives are.

If the size of the data you’re working with is large compared to the memory available, then you just may not be able to perform some operations on the data unless you can do this in place.

When programmers talk about doing something in place, this means that you need to use the memory that some data already occupies and maybe a small amount extra. That’s it.

Let’s say that you need to rearrange some characters in a word. Maybe you want the characters to be in a random order or maybe just backwards. Instead of allocating more memory for a copy of the word that you’ll build from the original based on how you need the characters rearranged, an in place algorithm will swap two characters at a time right in the original word until you are done.

This has the advantage of not requiring any extra memory beyond a reasonable and fixed amount of memory. But it also has the downside that once you begin, then the original word is no longer available unless you reverse the work done.


What's on your mind?
On a scale of 0 to 10, how likely are you to refer us to friends?