Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Real life use of doubly linked list

When does using a doubly linked list seem to be best option in real life scenario? Can someone suggest practical use of it?

like image 733
Tanvi Patel Avatar asked Nov 17 '16 17:11

Tanvi Patel


People also ask

What is doubly linked list explain with real life examples?

A music player which has next and previous buttons. The Browser cache which allows you to move front and back between pages is also a good example of doubly linked list. Most Recently Used is also an example of DLL. A deck of cards in a game is a classic example of application of DLL.

What is doubly linked list and its applications?

Doubly linked list can be used in navigation systems where both forward and backward traversal is required. It can be used to implement different tree data structures. It can be used to implement undo/redo operations.

What is the real life example of linked list?

Previous and next page in a web browser – We can access the previous and next URL searched in a web browser by pressing the back and next buttons since they are linked as a linked list. Music Player – Songs in the music player are linked to the previous and next songs.

Why is doubly linked list necessary?

The most common reason to use a doubly linked list is because it is easier to implement than a singly linked list. While the code for the doubly linked implementation is a little longer than for the singly linked version, it tends to be a bit more “obvious” in its intention, and so easier to implement and debug.


2 Answers

Adding to templatetypedef's answer.

You consider following applications :

- A music player which has next and prev buttons.
- Represent a deck of cards in a game.
- The browser cache which allows you to hit the BACK-FORWARD pages.
- Applications that have a Most Recently Used list (a linked list of file names)
- Undo-Redo functionality

Any application where you want to traverse both side from specific point.

like image 178
sam_k Avatar answered Oct 21 '22 19:10

sam_k


In many operating systems, the thread scheduler (the thing that chooses what processes need to run at which times) maintains a doubly-linked list of all the processes running at any time. This makes it easy to move a process from one queue (say, the list of active processes that need a turn to run) into another queue (say, the list of processes that are blocked and waiting for something to release them). The use of a doubly-linked list here allows each of these splices and rewires to run in time O(1) and without any memory allocations, and the doubly-linked-list structure works well for implementing the scheduler using queues (where you only need to pull things out from the front.)

like image 38
templatetypedef Avatar answered Oct 21 '22 18:10

templatetypedef