Comments on: Memory Efficient doubly linked list https://demo.ritambhara.in/memory-efficient-doubly-linked-list/ Coding / System Design Interviews Mon, 23 Apr 2018 05:55:11 +0000 hourly 1 https://wordpress.org/?v=6.8.2 By: Raghav Sharma https://demo.ritambhara.in/memory-efficient-doubly-linked-list/#comment-1750 Mon, 23 Apr 2018 05:55:11 +0000 http://www.ritambhara.in/?p=447#comment-1750 Value of Pointer =(Add of Prev Node) ^ (Link of Current Node)
Here we need to know “the Add of Prev Node” as well so we must be storing it somewhere, then how is it helping in less of memory?

]]>
By: Ashish Ahuja https://demo.ritambhara.in/memory-efficient-doubly-linked-list/#comment-1749 Fri, 11 Mar 2016 08:24:06 +0000 http://www.ritambhara.in/?p=447#comment-1749 In reply to Kamal Rawat.

Well, this is impractical. When you’re creating something for amazon or google, and require 100,000 nodes, you won’t use a doubly linked list. At that time, the main problem will be searching, inserting deleting, and the time taken by them. Thus, you will use a hash table, or something like that.

]]>
By: Hengameh https://demo.ritambhara.in/memory-efficient-doubly-linked-list/#comment-1748 Fri, 26 Jun 2015 06:11:21 +0000 http://www.ritambhara.in/?p=447#comment-1748 Thank you for your post; is there any java implementation for this?

]]>
By: Kamal Rawat https://demo.ritambhara.in/memory-efficient-doubly-linked-list/#comment-1747 Thu, 28 Mar 2013 04:07:50 +0000 http://www.ritambhara.in/?p=447#comment-1747 In reply to Sahil Sachdeva.

You are right Sahil.. I should have mentioned this in limitations.. thanks for pointing it out.

]]>
By: Sahil Sachdeva https://demo.ritambhara.in/memory-efficient-doubly-linked-list/#comment-1746 Wed, 27 Mar 2013 14:55:05 +0000 http://www.ritambhara.in/?p=447#comment-1746 doubly linked list has a quality that if i provide you with a node address present in that list you can tell the address of the node previous to it and next to it in constant time but i don’t think this can be done using XOR linked list…
Do you agree???
Please explain..

]]>
By: Kamal Rawat https://demo.ritambhara.in/memory-efficient-doubly-linked-list/#comment-1745 Fri, 07 Sep 2012 08:25:54 +0000 http://www.ritambhara.in/?p=447#comment-1745 In reply to Rodney.

Actually this is a classical time v/s memory question.. because you are saving on memory but loosing on time (traversal will be costly).. so a decision need to be taken.

]]>
By: Kamal Rawat https://demo.ritambhara.in/memory-efficient-doubly-linked-list/#comment-1744 Fri, 07 Sep 2012 07:51:05 +0000 http://www.ritambhara.in/?p=447#comment-1744 In reply to Rodney.

Imagine a complex application like that of google or amazon or ebay.. they must be dealing with so many data structures which may get created per user..
If google is able to save even 1byte of memory per user.. then google will save millions of bytes of server memory(because there must be millions of users accessing google at the same time)..

]]>
By: Kamal Rawat https://demo.ritambhara.in/memory-efficient-doubly-linked-list/#comment-1743 Fri, 07 Sep 2012 07:47:12 +0000 http://www.ritambhara.in/?p=447#comment-1743 In reply to Rodney.

You are right in the numbers.. just another way of looking at it can be: If doubly linked list is storing int, then the memory required by the list will be 2/3′rd (two-third) of the one required in the original version.
Saving 33% of memory to me looks like a lot of memory..
Plus for real application, 100000 nodes is not too large a list.. I mean my real life project may be using 1000 lists, and each of the list has 100 elements.. this is a usual expectation.. imagine storing the employee information (ID’s) in a list.. Having 1000 employees is not a big number.. plus another list used for resources in the company (PCs, Monitors, Printers, Laptops, Mobiles etc).. where the list is storing serial numbers of the devices.. this list can easily have 10000 nodes.. and so on.. so the Office Project may be using some thousands of list (some may be persistent also) and each list may be having some 10000s of nodes..
If you have a requirement where you are just dealing with few hundred nodes, then its not really worth it..

]]>
By: Rodney https://demo.ritambhara.in/memory-efficient-doubly-linked-list/#comment-1742 Fri, 07 Sep 2012 06:30:53 +0000 http://www.ritambhara.in/?p=447#comment-1742 You claim “a lot of memory savings”, because you only use one pointer instead of two. A typical pointer is 4 bytes on 32 bit and 8 bytes on 64 bit (not talking about function pointers which are a little different). So lets say you have a ridiculously large doubly linked list with 100,000 nodes. You only save only 390 KB on a 32 bit machine and 781 KB on a 64 bit machine. However with a more realistic size of lets say 100 you are only saving 0.39 KB on a 32 bit machine and 0.78 KB on a 64 bit machine.
So even if you are on a embedded system the complexity added by using XOR logic to use only a single pointer is not worth it. Its a great research project or assignment in college but in the real world where you want maintainable code and the KISS principle is king.

]]>