When is doubly linked list more efficient than singly linked list?

后端 未结 6 985
萌比男神i
萌比男神i 2020-12-07 14:09

In an interview today I got asked the question.

Apart from answering reversing the list and both forward and backward traversal there was something \"fundamental\"

6条回答
  •  孤街浪徒
    2020-12-07 14:32

    Here are my thoughts on Doubly-Linked List:

    • You have ready access\insert on both ends.

    • it can work as a Queue and a Stack at the same time.

    • Node deletion requires no additional pointers.

    • You can apply Hill-Climb traversal since you already have access on both ends.

    • If you are storing Numerical values, and your list is sorted, you can keep a pointer/variable for median, then Search operation can be highly optimal using Statistical approach.

提交回复
热议问题