On Mon, 09 Mar 2020 07:32:28 GMT
Jan Panteltje wrote:
> Nice, I like linked lists.
All right time to share an ancient hack (that I actually used once).
You have a single linked list which you wish was a double linked
list but due to resource limits you can't simply create a double linked
list and copy the data you have to convert it in place without using any
extra space. How ? (You may assume the list uses integers as pointers).
.
thinking space
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Instead of 'next' the pointer field contains 'next xor previous'
provided you know where you came from 'last' you go to 'last xor pointer'
to continue in the same direction.
--
Steve O'Hara-Smith | Directable Mirror Arrays
C:\>WIN | A better way to focus the sun
The computer obeys and wins. | licences available see
You lose and Bill collects. | http://www.sohara.org/
--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)
|