Print the Elements of a Linked List

Sort by

recency

|

866 Discussions

|

  • + 0 comments

    Just like layers of river rocks stack up beneath the earth over time, each node in a linked list connects to the next solid, grounded, and part of a bigger structure.

  • + 0 comments

    Here's a solution in C#

    static void printLinkedList(SinglyLinkedListNode head) {
            while(head != null){
                Console.WriteLine(head.data);
                head = head.next;
            }
        }
    
  • + 0 comments

    Python

    def printLinkedList(head):
        while head:
            print(head.data)
            head=head.next
    
  • + 0 comments

    Java 8 SinglyLinkedListNode current = head; while (current != null) { System.out.println(current.data); current = current.next; }

  • + 0 comments

    Why my code is not working? Javascript mode. In google debbuger is printing each element.

    function print (head){ if(head.length == null){ return null } else { for(let i = 0; i < head.length; i++){ console.log(head[i]) } } }