Added: 2 years ago
From: lcc0612
Views: 6,700
Sort by time | Sort by thread (beta)

Link to this comment:

Share to:

All Comments (19)

Sign In or Sign Up now to post a comment!
  • Do you have to catch a bus? The video is very fast to understand.

  • How can the algorithm backtrack up, if each node only holds a left and right pointer? This is the part that's confusing me the most. Also, how would the algorithm recognize that the node that it's backtracking up to is the correct one? What is the algorithm for that?

  • @NeoXC

    The backtracking is a property of recursive functions. Take for example:

    function f(n)  print n if n>=1 then f(n-1) end print n + "again!"

    end

    What happens is that, if i call f(2), f(2) will proceed to call f(1). Notice how, that at this point of time, the first call for f isn't finished yet, but it must wait till f(1) is done, and it will "automatically" backtrack to f(2) to print "2 again!"

    Hope this is clear. Look up recursion or leave another comment if you need more help!

  • @lcc0612 Thank you very much for your reply! I had a simple concept of recursive functions, but never knew that recursive functions return to previous calls. Thanks to you, I now understand how this works :)

  • @lcc0612 I've been having trouble with recursion for a long time, and I always avoid it, but here it seems it can not be left out. Can you recommend any good videos on recursion that would help me understand the binary tree sorting algorithms?

  • @they0killed0kenny

    To be honest, I haven't really come across any that's really simple and easy to understand. I'll send you a message if I ever see one.

  • Wow you talk fast! 

  • Way too fast....

  • Thanks for the help.

  • @meedowi

    Cheers! Glad I could be a help!

  • great job

  • @cloudgiant

    Thank you very much! I'm glad I could be of help!

  • Preorder and Inorder are correct. Great Work!

    Postorder is incorrect.

    The following rule applies to postorder. Postorder will always end with the root.

    2 1 4 3 7 8 11 10 9 6 5

    Post Order pseudocode

    If root is null return

    Postorder(left)

    Postorder(right)

    Postorder(root)

    Reference: Java Software Structures by Lewis Chase

  • @cody8092

    Thanks a lot for that! My understanding of post-order traversal is rather shaky, and I originally had a segment that explained it, but it looked wrong so i took it out. At least now I know where the mistake is! =D

  • Fantastic Video! Bravo!

  • @BourneInDenver

    Thanks! Glad you found it helpful!

  • thanks! that was interesting..

  • u should do one on traversal of trees

  • @zachgoestoeuro

    I originally incorporated that into this episode, but there were some errors and I didn't have time to re-record, so I had to cut out some stuff, and remove post-order traversal completely. I'l see what I can do about this!

Loading...
Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more