/node-linked_list

This repository demonstrates the usage of a doubly linked list in JavaScript, simulating a subway line with stops from Central Park to the Brooklyn Bridge.

Primary LanguageJavaScript

Doubly Linked List Example: Subway Line Simulation

This repository demonstrates the usage of a doubly linked list in JavaScript, simulating a subway line with stops from Central Park to the Brooklyn Bridge.

Features:

DoublyLinkedList.js: Implementation of a doubly linked list data structure. subway.js: Example usage of the doubly linked list to model a subway line. Node.js: Definition of the Node class used in the doubly linked list.

Instructions:

The subway line starts at Central Park and winds its way downtown. Stops include Times Square and Grand Central. Continuing downtown, stops are added to the subway line: Penn Station, Wall Street, and the Brooklyn Bridge. Construction occurs, closing Central Park and Brooklyn Bridge stops. The code uses removeHead() and removeTail() to handle closures without iterating through the entire list. The Times Square station is also closed. It is removed from the list. The final state of the subway line is printed after each modification. Feel free to explore, use, and adapt this code for your own projects!