Beginner tree algorithms | Graph Theory

แชร์
ฝัง
  • เผยแพร่เมื่อ 20 มิ.ย. 2024
  • Beginner tree algorithms: tree height and leaf sum
    Support me by purchasing the full graph theory course on Udemy which includes additional problems, exercises and quizzes not available on TH-cam:
    www.udemy.com/course/graph-th...
    Algorithms repository:
    github.com/williamfiset/algor...
    Next video (rooting a tree):
    • Rooting a tree | Graph...
    Video slides:
    github.com/williamfiset/Algor...
    0:00 Intro
    0:40 Problem 1: Leaf node sum
    2:19 Problem 1: Pseudocode
    3:32 Problem 2: Tree height
    6:50 Problem 2: Pseudocode
    8:25 Problem 2: Tree height simplification
    ===================================
    Practicing for interviews? I have used, and recommend `Cracking the Coding Interview` which got me a job at Google. Link on Amazon: amzn.to/3cvMof5
    A lot of the content on this channel is inspired by the book `Competitive Programming` by Steven Halim which I frequently use as a resource and reference. Link on Amazon: amzn.to/3wC2nix

ความคิดเห็น • 41

  • @suyashmisra7406
    @suyashmisra7406 4 ปีที่แล้ว +25

    I'm sure you've heard this a lot before,but I must say that you teach a lot better than my DS professor. Keep up the good work,and stay safe!

    • @WilliamFiset-videos
      @WilliamFiset-videos  4 ปีที่แล้ว +3

      Glad to help!

    • @abhijit-sarkar
      @abhijit-sarkar 11 หลายเดือนก่อน

      My DS prof couldn't teach even if his life depended on it. He came to the class with a stack of yellowed notes, copied that onto the blackboard, and read from the notes when asked a question. If you skipped his class, he'd find a way to give you low grades in his papers. Mind that I graduated from one of the top universities in the country. Can you imagine how many futures this f* guy ruined?

  • @pijushbhuyan9602
    @pijushbhuyan9602 4 ปีที่แล้ว +1

    Your videos are so well explained and easy to understand. Thanks for providing us such a high quality material

  • @JustmeAgain89
    @JustmeAgain89 ปีที่แล้ว +1

    This playlist will pass the test of time.

  • @DS-nr9zc
    @DS-nr9zc 3 ปีที่แล้ว

    really enjoying this playlist during quarantine!

  • @simontai3900
    @simontai3900 3 ปีที่แล้ว +1

    Really enjoy watching your videos, learnt a lot of things and a nice thing I would like to mention is the code quality, one function only do one thing even the logic can be written in one line, which make the code much more readable.

  • @niazahsan1337
    @niazahsan1337 3 ปีที่แล้ว

    Appreciate the calmness of your voice.

  • @bingxie342
    @bingxie342 4 ปีที่แล้ว +1

    always high quality!

  • @_withoutwax
    @_withoutwax 4 ปีที่แล้ว

    Thanks for the amazing video!

  • @BharCode09
    @BharCode09 4 ปีที่แล้ว +1

    Good to notice a video of recent time.. Thats some nostalgic music in the beginning! :) Thanks for making these great videos..

  • @nicepg
    @nicepg 3 ปีที่แล้ว

    These videos are amazing!!

  • @delongli4678
    @delongli4678 4 ปีที่แล้ว

    Greate Job! Thank you!

  • @remotetechie6910
    @remotetechie6910 4 ปีที่แล้ว +12

    I don't do Java, so I really love that code is in pseudo

    • @amrutya3298
      @amrutya3298 3 ปีที่แล้ว

      It's not in Java :)

  • @akshatbhutra4592
    @akshatbhutra4592 4 ปีที่แล้ว

    Sir I follow ur every video

  • @mikemihay
    @mikemihay 4 ปีที่แล้ว

    Big Like! Thank you

  • @nikhildinesan5259
    @nikhildinesan5259 3 ปีที่แล้ว

    Awesome videos!!!🔥🔥

  • @prashantbhrgv
    @prashantbhrgv 4 ปีที่แล้ว +1

    Hi William, Great videos! Really informative. Can you please share about how you create video slides?

    • @WilliamFiset-videos
      @WilliamFiset-videos  4 ปีที่แล้ว +1

      With Keynote:
      github.com/williamfiset/Algorithms/tree/master/slides

  • @developmentarchive5642
    @developmentarchive5642 3 ปีที่แล้ว

    For the first problem, does it means that only rooted trees have leaves? Otherwise how can you traverse from a root node?

  • @mengyichen3264
    @mengyichen3264 3 ปีที่แล้ว +1

    I have a question here 8:27
    Still didn't get the idea why removing the leaf- checking base case is ok?
    I think the statement of "correcting tree height" is not convincing.

  • @vijaybhatt8467
    @vijaybhatt8467 2 ปีที่แล้ว

    Hi William, in the leafSum algorithm, you have one with the nodes with three children. I am assuming we would be using an adjacency list to store this tree. Please correct me if we have to do it differently.

    • @WilliamFiset-videos
      @WilliamFiset-videos  2 ปีที่แล้ว +1

      Please watch th-cam.com/video/1XC3p2zBK34/w-d-xo.html, essentially we have a rooted tree and each node has a reference to a list of all its children.

  • @avoriginal9342
    @avoriginal9342 21 วันที่ผ่านมา

    What I don’t understand if you could please explain is why h-1 is used on every subtree, so for example, x root, go right have a z node, left of z node is another Y node, left of the Y node we have just a triangle (working on double rotation) which has a height of h-1, right of the Y node we have another triangle which has the height of h-2, right of Z node we have a triangle which is again h-1. Left of root x we have one triangle that is h-1, now where do these h-2 and h-1 come from. Also when checking the imbalance, a h+1 comes in to make it an imbalance of 2. How does this work, I can’t wrap my head around it. PLEASE HELP

  • @jackaus1742
    @jackaus1742 4 ปีที่แล้ว

    William must have a good taste of music. ;)

  • @cococu1847
    @cococu1847 3 ปีที่แล้ว

    Hi William I have access to my company udemy account. I already bought the Graph Theory Algorithms course. However, I am not able to access the Easy to Advanced Data Structures. I guess it due to this course is different category which is not covered by my company. Would you be able to create a copy of "Easy to Advanced Data Structures" under "IT & Software
    Other IT & Software
    Algorithms", I believed many users are also facing the same issue. I can provide more details if requires. Hope you can help. Thanks.

  • @sankalppatil2994
    @sankalppatil2994 2 ปีที่แล้ว

    Great video! This channel gives me 3blue1brown vibes.

  • @user-nt3cb8oq3k
    @user-nt3cb8oq3k 4 ปีที่แล้ว

    code was written by python?

    • @ENTphysician
      @ENTphysician 4 ปีที่แล้ว +1

      It's pseudo-code but very close to python syntax

  • @zarifmuhtasim
    @zarifmuhtasim 6 หลายเดือนก่อน

    couldn't you just loop through the nodes and sum up the values of the nodes whose out degree is 0?

  • @droneguy69
    @droneguy69 2 ปีที่แล้ว

    What programming language is this?

  • @antongromov8093
    @antongromov8093 3 ปีที่แล้ว

    2:01
    Forgot to add 7?

    • @interstella5555
      @interstella5555 3 ปีที่แล้ว +1

      7 is not a leaf node, it has a child

    • @antongromov8093
      @antongromov8093 3 ปีที่แล้ว

      @@interstella5555 oh... made a mistake. Thanks

  • @considerphi
    @considerphi 2 ปีที่แล้ว +2

    Actually it looks like he's copied your whole set of videos into a "course".

  • @katemorse2791
    @katemorse2791 2 ปีที่แล้ว

    Can I marry you?

  • @avoriginal9342
    @avoriginal9342 21 วันที่ผ่านมา

    What I don’t understand if you could please explain is why h-1 is used on every subtree, so for example, x root, go right have a z node, left of z node is another Y node, left of the Y node we have just a triangle (working on double rotation) which has a height of h-1, right of the Y node we have another triangle which has the height of h-2, right of Z node we have a triangle which is again h-1. Left of root x we have one triangle that is h-1, now where do these h-2 and h-1 come from. Also when checking the imbalance, a h+1 comes in to make it an imbalance of 2. How does this work, I can’t wrap my head around it. PLEASE HELP