Introduction to Linked Lists (Data Structures & Algorithms #5)

20
11



Learn the basics of linked lists. Java & Python sample code below.

Check out Brilliant.org ( a website for learning math and computer science concepts through solving problems. First 200 subscribers will get 20% off through the link above.
Special thanks to Brilliant for sponsoring this video.

Find sample code in Python and Java here:

This was #5 of my data structures & algorithms series. You can find the entire series in a playlist here:

Also, keep in touch on Facebook:

Nguồn:https://wijstaanvooronzegrondrechten.org/

20 COMMENTS

  1. Hey everyone! If you are looking for more practice problems for arrays and linked lists, I’d also recommend my Udemy course, “11 Essential Coding Interview Questions” here: https://goo.gl/v35LCa

    It’s supposed to be for programming interview questions, but it should be a good resource for improving your problem-solving skills in general.

    Anyway, thanks as always for watching! If you don’t want to pay for the course, remember that I have a ton of other free videos right here on this YouTube channel 🙂

  2. def count_nodes(node):

    count = 1

    if node.next_node is not None: count = count + count_nodes(node.next_node)

    return count

  3. You're an incredible teacher. Hope these videos never end and stretch across even the most advanced of topics. Very enjoyable.

  4. public static int countNode(ListNode head) {

    int count = 1;

    while (head.next != null) {

    count++;

    head = head.next;

    }

    return count;

    }

  5. static int countNodes(Node head){

    int count=0;

    Node temp=head;

    while(temp!=null){

    temp=temp.next;

    count++;

    }

    return count;

    }

  6. How did you implement the linked list class? I dont remember seeing you do it but I might have not been paying complete attention. Also is the next video on linked lists out yet?

  7. in C#
    int CountNodes(Node head)
    {
    if(head == null)
    return 0;

    int count=1;
    Node curr = head;
    while(curr.next != null){
    curr=curr.next;
    count++;
    }

    return count;

    }

  8. Hey….I have watched several videos but didn't understand how linked lists exactly worked. After watching ur video I have understood exactly how they work. Great explanation. However, I'm really sad to know that you don't post any videos now. Please let us know why.

  9. I did it recursively:

    public int countNodes(Node head) {
    int count = 0;
    return countNodesHelper(head, count);
    }

    private int countNodesHelper(Node node, int count) {
    if (node != null) {
    return countNodesHelper(node.next, count+1);
    }
    return count;
    }

  10. public static int countNodes(Node head) {
    int count = 0;
    Node temp = head;

    if (head != null) {
    count++;

    while (temp.next != null) {
    count++;
    temp = temp.next;
    }
    }

    return count;
    }

  11. I understand now what node is and head and also data. Tnx for information man, more power to your channel

LEAVE A REPLY

Please enter your comment!
Please enter your name here