Skip to main content

Posts

Showing posts with the label javascript

Intro To Data Structures - Linked Lists

Linked Lists       A linked list is a linear data structure, whose order is not given by their physical placement in memory. Instead, it   consists of nodes where each node contains a data field and a pointer to the next node in the list. Which means linked lists are stored in non-contiguous blocks of memory. Creating A Node Constructor     The first step in creating a Linked List is to build the Node Class Constructor. The node will have two variables, the data and the pointer to the next node. Whenever the Linked List goes to make a new node, it will create an instance of the Node class. class Node { constructor ( data , next ) { this . data = data ; this . next = next ; } } Building A Linked List     Now it's time to start building the Linked List. We are going to use a Class Constructor to create the foundation for our Linked List. The list is going to have two values, the head and the size of the list. The head is