Tree traversal algorithms (BFS and DFS - Preorder, Inorder, Postorder)

แชร์
ฝัง
  • เผยแพร่เมื่อ 5 พ.ย. 2024

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

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

    📚 Learn how to solve problems and build projects with these FREE E-Books ⬇️
    C++ Lambdas e-book - free download here: bit.ly/freeCppE-Book
    Entire Object-Pascal step-by-step guide - free download here: bit.ly/FreeObjectPascalEbook
    🚀📈💻🔥 My Practical Programming Course: www.codebeautyacademy.com/
    Experience the power of practical learning, gain career-ready skills, and start building real applications!
    This is a step-by-step course designed to take you from beginner to expert in no time!
    💰 Here is a coupon to save 10% on your first payment (CODEBEAUTY_YT10).
    Use it quickly, because it will be available for a limited time.
    Code from this video:
    #include
    using namespace std;
    struct Node {
    int data;
    Node* left;
    Node* right;
    };
    Node* createNode(int data) {
    Node* newNode = new Node();
    newNode->data = data;
    newNode->left = newNode->right = nullptr;
    return newNode;
    }
    void printTree(Node* root) {
    if (root == nullptr) return;
    //preorder algorithm (D,L,R)
    cout data left);
    printTree(root->right);
    }
    int main()
    {
    //Level 1
    Node* root = createNode(1);
    //Level 2
    root->left = createNode(2);
    root->right = createNode(3);
    //Level 3
    root->left->left = createNode(4);
    root->left->right = createNode(5);
    root->right->left = createNode(6);
    root->right->right = createNode(7);
    //Level 4
    root->left->right->left = createNode(9);
    root->right->right->left = createNode(15);
    printTree(root);
    cin.get();
    }

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

      You very beautiful im afraid that if i will watch to much your videos i will fall in love😂😂

    • @interestingmusic9578
      @interestingmusic9578 ปีที่แล้ว

      .

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

    Amazing video! I can't explain how long I've been looing for a good explanation, glad I finally found it.

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

      Thanks mrs. puff for the vid

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

    Your video lessons are so helpful for my coding journey. The things which are hard to understand in textbook is easy to follow on your tutorial. Thanks for your amazing work ❤️

  • @МаксСивухо
    @МаксСивухо 2 ปีที่แล้ว +12

    Hello. It is the best explanation I've ever seen. Thank you for your lessons

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

      I'm glad to hear that and happy to help 😃😃

  • @md.abubakkarsiddiq1156
    @md.abubakkarsiddiq1156 2 ปีที่แล้ว +20

    4,9,5,2,6,15,7,3,1 is the post order traversal. Is this the correct answer, please let me know.

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

    Hi, this channel is pure gold, is understandable even for an italian like me. Thank you very much.

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

    Cool! Very simple explaining. Thank you so much!!!

  • @GMTX-qj8or
    @GMTX-qj8or 2 ปีที่แล้ว +4

    Thank you for a great paced and visual explanation of the topic, keep up the great work, the e-books are great.

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

    These books are amazing, thanks for sharing free resources with us Saldina ❤️

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

    since you're learning algorithms like the video it helps youtube algorithms
    CLASSIC!!

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

    You explain very well 😉

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

    Very refreshing video... keep the good work up.

  • @charleswayne5581
    @charleswayne5581 5 หลายเดือนก่อน

    This is the most excellent explanation on recursion I have ever seen!

    • @CodeBeauty
      @CodeBeauty  5 หลายเดือนก่อน

      I'm glad that you like it 🤗 🥰

  • @jliu7221
    @jliu7221 ปีที่แล้ว

    Better explained than those tedious and never-ending college CS courses. I enjoy your instructions. Simply Amazing!

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

    //Postorder algorithm (L,R,D)
    printTree(root->left);
    printTree(root->right);
    cout data

  • @Daniel-um9ye
    @Daniel-um9ye 2 ปีที่แล้ว

    You managed to make this look super easy. The best traversing trees tutorial I have seen ( and I have seen a lot of them ).

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

    Omg! I have never understood how a recursive function works until I watched this video! Your explanations are top notch!

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

    This is the clearest explanation of DFS algorithms that I've seen. Thank you for making it easy (where my book and lecturer did not)!

  • @deli5777
    @deli5777 ปีที่แล้ว

    Maybe the most helpful video on recursion that I've seen

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

    very comprehensive video Saldina.Your english also are awesome.Can you make if you find free time more video about windows forms applications?

  • @munib2023
    @munib2023 5 หลายเดือนก่อน +1

    Upload all your STL videos in a single video as you did in C++.
    This will helped us alot.

  • @029_shauryaagarwal8
    @029_shauryaagarwal8 2 ปีที่แล้ว +9

    My placement session is coming, can you make more such videos on Data structures and algorithms, your explanations are very good🔥❤️

  • @HiMiss940
    @HiMiss940 8 หลายเดือนก่อน +1

    Your English is really good , i mean really easy to understand, good Word Choice ❤❤😊

  • @Pirzade
    @Pirzade 4 หลายเดือนก่อน

    One word is enough : Incredible.

  • @Tech_Diaries_With_Vincent
    @Tech_Diaries_With_Vincent 4 หลายเดือนก่อน +1

    Thank you for this video, you made this topic and concept more understandable 😍

    • @CodeBeauty
      @CodeBeauty  4 หลายเดือนก่อน +1

      You're welcome 😊 🥰

  • @AryanSingh-6699
    @AryanSingh-6699 2 ปีที่แล้ว +14

    ❤ Love from India 🧡🤍💚

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

      Love for India 🧡🤍💚

  • @МаксимУдовиченко-и1м
    @МаксимУдовиченко-и1м 2 ปีที่แล้ว

    Hello, Saldina! I am a Russian developer. Your videos are amazing! You explain the topic very clearly, giving examples from life! Looking forward to your new videos!

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

      Я люблю Россию

  • @潘建廷-g3o
    @潘建廷-g3o 2 ปีที่แล้ว +1

    Excellent video!!
    Could you update more algorithm-related Videos in the future?
    Your explanation is simple and good to understand.

  • @SatishSingh-cp3wo
    @SatishSingh-cp3wo ปีที่แล้ว

    The way you explain, even a 5th grader will understand. 🤜🤛

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

    This is the best explanation. Thank you soooooo much!!!

  • @itsme17717
    @itsme17717 11 หลายเดือนก่อน +1

    you are awesome, I really understand trees right now

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

    Thank you for this video. You are a really good teacher. Please make a video about BFS as well 🙏

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

      Great suggestion! :D

  • @hulkio22
    @hulkio22 8 หลายเดือนก่อน +1

    AWESOME explanation!!!. Thanks a lot!!!

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

    nice video!

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

    A good revision session (been ages!)
    Thank you Ma'am!

  • @kf4547
    @kf4547 ปีที่แล้ว

    Such a great explanation of the themes! Thank u very much, we appreciate your work

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

    back at it with the bangers I really thank you for this!

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

    Great explanation. God bless you 🙏

  • @Pirzade
    @Pirzade 4 หลายเดือนก่อน

    I want to add something. There are 6 possibilities for Depth First Search Algorithm according to the starting point in data structure. D refers to the Data, L refers to the Left, R refers to the Right pointer. The possibilities are; A-PreOrder (1-DLR, 2-DRL), B-InOrder (3-LDR, 4-RDL), C-PostOrder (5-LRD, 6-RLD)

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

    it is truely code beauty for many reason

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

      thank you, did you check my C# Practical Programming Course at www.codebeautyacademy.com
      ??

  • @vincent_muriithi
    @vincent_muriithi 4 หลายเดือนก่อน

    amazing, kindly create a BFS traversal algorithm video 😍

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

    The hardest thing about coding is not seeing what it does in the background. Your explanation is amazing and this is what people hope to see, especially me. Thank you so much!

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

    This video was SO helpful! I was struggling with this topic but it was so easy and simple to understand with you! Really appreciate you!

  • @putin_navsegda6487
    @putin_navsegda6487 ปีที่แล้ว

    Wow great explanation ! Finally i understand it😁

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

    I wanna learn

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

      Go ahead 😃😃

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

    very easy to understand. thanks for making such useful videos

  • @danonuevo
    @danonuevo ปีที่แล้ว

    Hello, thank you so much, and it's a very concise explanation for the DFS. May we request how about doing BFS with the same Tree example. More tutorial videos to come.

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

    From a brown-skinned Mexican, i say thanks, these videos of yours are absolutely BRILLIANT! They are helping me in my engineering classes, so again, thanks.

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

    Thank you so much! Please please make a video of BFS!

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

    Amazing video, thank you so much for this !

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

    Hi Saldina! Amazing video :D I was wondering if in the future if you give a tutorial on vectors in C++? Most of the tutorials I looked up are a bit confusing and I feel like you can give some o fun clarity on this topic like you do with your other videos.

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

    your video are so helpful

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

    Plz make video for B-tree 🙏🙏

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

    Excellent explanation!

  • @Data_Science_In_Kannada
    @Data_Science_In_Kannada 8 หลายเดือนก่อน

    great video, everything was understood so easily! can I get link for BFS?

  • @tofiq62
    @tofiq62 ปีที่แล้ว

    Very good explanation! 👏

  • @nika_nothingmore
    @nika_nothingmore ปีที่แล้ว

    your videos are amazing!

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

    Many thanks for your explanations. Hope you to make a video about hash table soon.

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

    Explaining recursive functions is challenging and often confusing to the neophyte. Nevertheless, you tackled the challenge faultlessly. One wonders if, when searching, the algorithms would be more efficient if one compared the 'target' with the data and choosing the appropriate algorithm on the result. Are there generic algorithms for balancing the tree, should one side of a node gets much 'heavier' than the other?

  • @kwizeraenock1639
    @kwizeraenock1639 ปีที่แล้ว

    Thank you saldina for your help ❤

  • @mr.potato8894
    @mr.potato8894 2 ปีที่แล้ว +8

    Is it possible to get a virtual autograph? 😂😂

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

      Hahahha, I was wondering the same :D

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

      Hahaha, something like my digital signature 😁
      Maybe I'll make a few NFTs in the future and share them with my most active viewers 🤔😃

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

      @@CodeBeauty this video is definitely worth of a coffee at least, I'll check how that works...

  • @handover007
    @handover007 5 หลายเดือนก่อน +1

    You teaches so nicely , your lectures sounds like music.

    • @CodeBeauty
      @CodeBeauty  5 หลายเดือนก่อน +1

      I'm happy to hear that 🥰

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

    I saw u an year ago
    U have changed alot😳

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

    This helps so much. Thank you!

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

    Thenk you I learn a lot from you.

  • @YaXiao-wv4rm
    @YaXiao-wv4rm 7 หลายเดือนก่อน

    What you said is great!

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

    Hi, thanks for your explanation. I have questions about types of Trees and how they are used. Black-Red Tree for example. Or in which case we use DFS ? Thanks.

  • @SaiGanesh314
    @SaiGanesh314 ปีที่แล้ว

    Waiting for a video on BFS algorithm.... :))

  • @madhusankawijerathne8435
    @madhusankawijerathne8435 ปีที่แล้ว

    Really helpful. Thank you!

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

    Please upload more videos on tree, if you have any paid courses please embed the link in the description

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

    Thank you saldina
    I hope you make vedio's about problem solving

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

    amazing video I finally understand DFS ❤ ;
    can I ask you to make a video explaining BFS and red and black tree
    thank you

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

    can you make more such videos on Data structures and algorithms?
    your explanations are very nice,and you are so beautyfull hhhh.
    thanks for you.

  • @Happys_Art
    @Happys_Art ปีที่แล้ว

    Hello. Is it okay to use this code for my homework assignment for my class. To be honest I’ve ready used it for my assignment so technically I’m just informing you that I already used this code and wanted to ask if it was okay

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

    Thank you for this vedio but i wish you make vedios about solve problems using dfs I couldn't solve any problem until now using it

  • @Marzex1x
    @Marzex1x 7 หลายเดือนก่อน

    Thank you!

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

    can you setup tour also i kinda waana know and thanks for the hard work....

  • @madhusankawijerathne8435
    @madhusankawijerathne8435 ปีที่แล้ว

    Thank you again

  • @mihnea-um5gy
    @mihnea-um5gy ปีที่แล้ว

    Will you do a video for BST?

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

    keep up the good work super useful

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

    Love your videos!

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

    perfect Explanation!

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

    Could you show me the BFS algorithm as well?

  • @MuhammadBilal-j9x
    @MuhammadBilal-j9x ปีที่แล้ว +1

    Hi i am trying to find how to deletion form Tree

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

    Hope everything is fine for you, following the earthquake in Stolac today!

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

      It was scary. Everything is fine with my family and all the people I know, but I read that there were some casualties.
      I hope that everything is okay with you, and I also hope that there will be no more earthquakes, because from what I read, a couple of them usually hits one after the other. That would be terrible 😰

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

    I love you videos thank you for share you knowledge question do you have Patrion ?

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

      I don't have Patreon, maybe in the future, currently I only have BuyMeACoffee 😊😃☕

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

    you're a life saver 😘😘

  • @انامسلموكفى
    @انامسلموكفى ปีที่แล้ว

    I ve a struct of student with some properties : code is the identifier of the student, it will be the node in the binary search tree , first i would like to create a linked list of int from this struct ?? And then convert this linked list to a bst in a dynamic way? Please help

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

    Gosh! Just in time!!!!

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

    BFS please!

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

    Please also do the breadth first search :)

  • @jamalparker4487
    @jamalparker4487 ปีที่แล้ว

    How does the algorithm know to go back up a node after reaching a node with no left or right linked node?

  • @veslyju1984
    @veslyju1984 ปีที่แล้ว

    At the part printTree(Node* root){}
    printTree(root); why there is no pointer to pointer like insert in linkedlist? Like printTree(Node** root){}
    printTree(&root); I mean like this ,isn't root point to other ?

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

    Hey, Can you please post more videos of data structures?

  • @097_suryakantdhote9
    @097_suryakantdhote9 2 ปีที่แล้ว

    Will you be doing a video on hash maps?

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

    Thank you!

  • @ilham-t9y
    @ilham-t9y ปีที่แล้ว

    11:56 how do the program know that the root is passed to the next node?

  • @ASHWANIKUMAR-fc5pu
    @ASHWANIKUMAR-fc5pu 2 ปีที่แล้ว +1

    kindly add more videos

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

    Iwanted to ask Where to learn about functions in headers file for c++ ?

  • @mehdi-vl5nn
    @mehdi-vl5nn 2 ปีที่แล้ว

    is any difference between traversal and lookup ?