Normal traversal

This is head to tail movement of the pointer in a list. The normal traversal is done as:

  • Create a pointer named curr as the current pointer.
  • Assign the value of the head to the curr pointer.
  • Move the curr pointer till the end and display output.
    • curr => curr.next

Example:

Javascript




// To traverse and display the list
display() {
    // Check if the List is empty
    if (!this.isEmpty()) {
        // traverse the list using new current pointer
        let curr = this.head;
        console.log("Required list is");
 
        while (curr !== null) {
            // Display element
            console.log(curr.data);
 
            // Shift the current pointer
            curr = curr.next;
        }
    }
}


How to traverse Doubly Linked List in JavaScript?

This article will demonstrate the Doubly Linked List Traversal using JavaScript. Traversal refers to the steps or movement of the pointer to access any element of the list.

Similar Reads

Types of Traversal in Doubly Linked List Using JavaScript

Normal Traversal: Traversing the list from Head to Tail of the list. Reverse Traversal: Traversing the list from the Tail element to the Head element of the list i.e. in reverse order....

Normal traversal

This is head to tail movement of the pointer in a list. The normal traversal is done as:...

Reverse traversal

...

Implementation of traversal in Doubly Linked List

This is head to tail movement of the pointer in a list. The normal traversal is done as:...