DEV Community

Cover image for Getting started with linked list

Posted on


Getting started with linked list

A linked list is a linear data structure, in which the elements are not stored at contiguous memory locations. The elements in a linked list are linked using pointers as shown in the image above.
In simple terms, a linked list consists of nodes where each node contains a data field and a reference to the next node in the list. the linked list is way different from the array data structures because in linked list the list only knows about the head and tail node while each element only knows about the next element after them.

Implementation of LinkedList in Javascript

We are going to implement append: to add values at the end of the list, prepend: to add values at the beginning of the list, find value: to search the list for a particular value, delete: to remove a value from the list, insert after: to insert a value just after a specified value, print values: to view all the values of the linked list.

vscode workspace for the implementation of linked list

insert after and print all values

vscode workspace for the implementation of linked list

thanks for your time, I have more post liked this to help you understand data structures, please keep checking.

Top comments (0)

11 Tips That Make You a Better Typescript Programmer


1 Think in {Set}

Type is an everyday concept to programmers, but it’s surprisingly difficult to define it succinctly. I find it helpful to use Set as a conceptual model instead.

#2 Understand declared type and narrowed type

One extremely powerful typescript feature is automatic type narrowing based on control flow. This means a variable has two types associated with it at any specific point of code location: a declaration type and a narrowed type.

#3 Use discriminated union instead of optional fields


Read the whole post now!