Kalkwst / MicroLib

MIT License
3 stars 0 forks source link

:sparkles: Add Doubly Linked List Implementation #21

Open Kalkwst opened 1 year ago

Kalkwst commented 1 year ago

A doubly linked list is similar to a regular linked list, but each node contains an additional reference to the previous node in the list. This allows for more efficient traversal in both directions, as you can move both forwards and backward through the list by following the references. This makes it useful for data structures that can traverse the list in both directions like queues and dequeues.

From a more technical perspective, a doubly linked list is a more advanced version of a linked list, where each node contains an additional pointer, typically called the previous pointer, in addition to the next pointer. This allows for the traversal of the list in both directions. The doubly linked list has a head and a tail that point to the first and last elements respectively. Each node in the doubly linked list contains three fields: data, previous pointer, and next pointer. The previous pointer of the head points to null and the next pointer of the tail points to null. This data structure allows for constant-time insertions and deletions at both ends, making it useful for implementing queues and dequeues. It also allows traversing the list in both directions, but it requires more memory to store the additional pointer in each node.

kgrontis commented 1 year ago

@Kalkwst Under which folder are we going to put the data structures? Should I create a new one and if yes, please provide information!

Kalkwst commented 1 year ago

Under the Collections Project, create a List folder and add the Doubly Linked List under that namespace.

In essence, every family of data structures (e.g., lists, maps, trees, heaps, etc) should be under their namespaces.