Print number of leaf nodes(leaves) in Binary Tree

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

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

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

    You explain things very well!!Congrats!!!
    Can you please tell me how to make a procedure that prints a particular node???

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

    You just made my day. Thank you!

  • @prince.kmr1
    @prince.kmr1 7 ปีที่แล้ว +5

    int total(struct node* root){
    if(root){
    if(!root->left && !root->right)
    return 1;
    return (total(root->left)+total(root->right));}
    }
    can be done like this too. But I really like your videos Sir.Keep uploading :)

    • @nands4410
      @nands4410 6 ปีที่แล้ว +3

      GeeksforGeeks Boi

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

      gives segsev for testcase having either left or right child due to not checking of null

  • @Akash-Bisariya
    @Akash-Bisariya 5 ปีที่แล้ว

    How easy you described and solved this problem... Awesome man. Many thanks to you..

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

    A Gnutella topology looks like a balanced ternary tree with 4 levels of nodes, i.e., peers, as shown in the picture below. Thus, there is 1 root at Level 1, which has 3 children at Level 2, which each have 3 children at Level 3, which in turn each have 3 children at Level 4 - thus, there are a total of 40 nodes.
    If the root node (Level 1) sends a Query message with TTL=2, then what are the number of nodes receiving the Query message, not including the originating node? Enter your answer as a numeric value in the text box below.

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

    Goat stuff right here

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

    Thanks for this
    How to input a general tree, only algorithm need ?

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

    How to print the count sir my count is printing as much my loop is executing .

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

    thank you

  • @sudarshannagaraj4458
    @sudarshannagaraj4458 6 ปีที่แล้ว

    Can u solve closest leaf distance from given k in a binary tree

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

    Thankx sir😄

  • @marwantariq8458
    @marwantariq8458 7 ปีที่แล้ว

    can you assist me with this method
    void IncrementLeaves( int value )
    - Function: adds value to all the leaves’ info.
    - Precondition: Tree has been initialized.
    - Postcondition: Function value = leaves’ info is increased by value.

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

    Great !!
    Keep it up!!

  • @divyajyotikumar8457
    @divyajyotikumar8457 7 ปีที่แล้ว

    Sir please post a video which Print Nodes having K leaves by iteration method and recursive too

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

      yes sure Divyajyoti......u want a n-ary tree?

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

      +Vivekanand Khyade - Algorithm Every Day
      no sir its binary tree but i want to print all nodes having k no of leaf nodes

  • @vlogbazz2.05
    @vlogbazz2.05 7 ปีที่แล้ว

    sir make a video on dbms and os

  • @Btc2Tao
    @Btc2Tao 6 ปีที่แล้ว +3

    There is no return statement in your solution ?

  • @alvinlepik5265
    @alvinlepik5265 6 ปีที่แล้ว

    Global parameter is a bad idea, since you leak information out of the method. We could parametrise count (root, count) and initialise as count (root_of_tree, 0).

  • @kj__entertainment
    @kj__entertainment 7 ปีที่แล้ว

    wah

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

    I think it should be in preorder traversal instead of inorder @5.49

  • @me_amir982
    @me_amir982 6 ปีที่แล้ว

    #Vivekananda sir apne email dedo kuch queries puchne k liye....

  • @nimishgupta5289
    @nimishgupta5289 5 ปีที่แล้ว

    int ans=0;
    int count(struct Node *root)
    {
    if(root==NULL)
    return 0;
    if(root->left)
    count(root->left);
    if(root->right)
    count(root->right);
    if(root->left && root->right)
    ans++;
    }
    Is this fine @vivekanand sir.