Microsoft Asks: Singly List or Doubly List? What are the pros and cons of using each?

.net, linked-list

Solution

I am asked such question and I have my own sayings but I am not really sure what to say about cons and pros?

It all comes down to usage. There's a trade off here.

Singly linked list is simpler in terms of implementation, and typically has a smaller memory requirement as it only needs to keep the forward member referencing in place.

Doubly linked list has more efficient iteration, especially if you need to ever iterate in reverse (which is horribly inefficient with a single linked list), and more efficient deletion of specific nodes.

That being said - since you have this tagged .NET, double linked lists also have the advantage of being directly in the framework in the form of the `LinkedList<T>` class. This provides a huge advantage in that you don't have to implement, test, and maintain your own collection class.

Problem

I am asked such question and I have my own sayings but I am not really sure what to say about cons and pros? Microsoft asked this question to one of its candidates. Singly linked list allows you to go one way direction. Whereas doubly linked list has two way direction next and previous. Here is a good picture which draws the Singly and Doubly LinkedLists. However, how do you explain the pros and cons of these items in more orderly fashion?

Original source

Related problems