Linked List in JavaScript

Soufiane Oucherrou
2 min readAug 23, 2020

--

I start recently practice and dive deeper in Data Structures and Algorithms, so I decided to share my journey with you guys,

I’m going to start with linked list because I believe it make for an important and effective educational tool in helping develop a student’s mental model on what data structures actually are to begin with.

Linked lists are simple. they need many compelling, reoccurring edge cases to think about that emphasize to the scholar the necessity for care and intent while implementing data structures. like Lists, Stacks, and Queues, and that they have A level of versatility high enough to obviously illustrate the worth of the thing Oriented Programming paradigm.

They also come up in software engineering interviews very often .

Linked List is ?

As a linear data structure, the elements of a linked list are not hosted in adjacent memory locations. Pointers, demonstrated visually below, are connected to a link list through these elements:

In simple words, a linked list consists of nodes where each node contains a data field and a reference(link) to the next node in the list.

Linked List Properties:

  • Head: The first node in the list.
  • Tail: The last node in the list.
  • Length: The number of nodes in the list; the list’s length.

Depending on the type of Linked List (there are many), Node instances track some very important properties as well.

Linked List Node Properties:

  • Data: The actual data this node represents.
  • Next: The next node in the list (relative to this node).

Linked Lists contain ordered data, just like arrays. The first node in the list is, indeed, first. From the perspective of the very first node in the list, the next node is the second node. From the perspective of the second node in the list

Arrays contain contiguous data. Each element of an array is really stored next to it is neighboring element within the actual hardware of your machine, during a single continuous block in memory.

Linked Lists contain non-contiguous data. Though Linked Lists represent data that is ordered linearly, that mental model is just that — an interpretation of the representation of information, not reality.

For more clarity, together we will implement some methods for Linked List to have better understanding

To Be Continued…

--

--

No responses yet