Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

binary trees

any one know a lot of this topic help me.....
«1

Comments

  • zibadianzibadian Member Posts: 6,349
    : any one know a lot of this topic help me.....
    :
    Here's a good explanation: http://en.wikipedia.org/wiki/Binary_tree

    Basically a binary tree can be build using a single type of object, which has two (or three) fields: left and right (and parent). The parent field is optional, but it makes traversing the tree upward quite easy.
  • glex911glex911 Member Posts: 11
    : : any one know a lot of this topic help me.....
    : :
    : Here's a good explanation: http://en.wikipedia.org/wiki/Binary_tree
    :
    : Basically a binary tree can be build using a single type of object,
    : which has two (or three) fields: left and right (and parent). The
    : parent field is optional, but it makes traversing the tree upward
    : quite easy.

    thanks pal.... it helps!
  • glex911glex911 Member Posts: 11
    : : : any one know a lot of this topic help me.....
    : : :
    : : Here's a good explanation: http://en.wikipedia.org/wiki/Binary_tree
    : :
    : : Basically a binary tree can be build using a single type of object,
    : : which has two (or three) fields: left and right (and parent). The
    : : parent field is optional, but it makes traversing the tree upward
    : : quite easy.
    :
    : thanks pal.... it helps!
    :

    i read it but dont read how to delete a node.
  • zibadianzibadian Member Posts: 6,349
    : : : : any one know a lot of this topic help me.....
    : : : :
    : : : Here's a good explanation: http://en.wikipedia.org/wiki/Binary_tree
    : : :
    : : : Basically a binary tree can be build using a single type of object,
    : : : which has two (or three) fields: left and right (and parent). The
    : : : parent field is optional, but it makes traversing the tree upward
    : : : quite easy.
    : :
    : : thanks pal.... it helps!
    : :
    :
    : i read it but dont read how to delete a node.
    :
    Here's how to insert and delete a node:
    http://en.wikipedia.org/wiki/Binary_search_tree
  • glex911glex911 Member Posts: 11
    : : : : : any one know a lot of this topic help me.....
    : : : : :
    : : : : Here's a good explanation: http://en.wikipedia.org/wiki/Binary_tree
    : : : :
    : : : : Basically a binary tree can be build using a single type of object,
    : : : : which has two (or three) fields: left and right (and parent). The
    : : : : parent field is optional, but it makes traversing the tree upward
    : : : : quite easy.
    : : :
    : : : thanks pal.... it helps!
    : : :
    : :
    : : i read it but dont read how to delete a node.
    : :
    : Here's how to insert and delete a node:
    : http://en.wikipedia.org/wiki/Binary_search_tree



    nice thanks pal.
  • glex911glex911 Member Posts: 11
    : : : : : : any one know a lot of this topic help me.....
    : : : : : :
    : : : : : Here's a good explanation: http://en.wikipedia.org/wiki/Binary_tree
    : : : : :
    : : : : : Basically a binary tree can be build using a single type of object,
    : : : : : which has two (or three) fields: left and right (and parent). The
    : : : : : parent field is optional, but it makes traversing the tree upward
    : : : : : quite easy.
    : : : :
    : : : : thanks pal.... it helps!
    : : : :

    finding mid and the max?
    : : :
    : : : i read it but dont read how to delete a node.
    : : :
    : : Here's how to insert and delete a node:
    : : http://en.wikipedia.org/wiki/Binary_search_tree
    :
    :
    :
    : nice thanks pal.
    :

  • glex911glex911 Member Posts: 11
    : : : : : : any one know a lot of this topic help me.....
    : : : : : :
    : : : : : Here's a good explanation: http://en.wikipedia.org/wiki/Binary_tree
    : : : : :
    : : : : : Basically a binary tree can be build using a single type of object,
    : : : : : which has two (or three) fields: left and right (and parent). The
    : : : : : parent field is optional, but it makes traversing the tree upward
    : : : : : quite easy.
    : : : :
    : : : : thanks pal.... it helps!
    : : : :

    finding mid and the max?
    : : :
    : : : i read it but dont read how to delete a node.
    : : :
    : : Here's how to insert and delete a node:
    : : http://en.wikipedia.org/wiki/Binary_search_tree
    :
    :
    :
    : nice thanks pal.
    :

  • zibadianzibadian Member Posts: 6,349
    : : : : : : : any one know a lot of this topic help me.....
    : : : : : : :
    : : : : : : Here's a good explanation: http://en.wikipedia.org/wiki/Binary_tree
    : : : : : :
    : : : : : : Basically a binary tree can be build using a single type of object,
    : : : : : : which has two (or three) fields: left and right (and parent). The
    : : : : : : parent field is optional, but it makes traversing the tree upward
    : : : : : : quite easy.
    : : : : :
    : : : : : thanks pal.... it helps!
    : : : : :
    :
    : finding mid and the max?
    : : : :
    : : : : i read it but dont read how to delete a node.
    : : : :
    : : : Here's how to insert and delete a node:
    : : : http://en.wikipedia.org/wiki/Binary_search_tree
    : :
    : :
    : :
    : : nice thanks pal.
    : :
    :
    :
    Finding the maximum and minimum is quite simple:
    Based on the text of the wikipedia:
    - Maximum is the right-most node
    - Maximum is the left-most node
    If the tree is balanced, then the middle is always the root, but for an unbalanced tree, it is easier to restructure it to a list.
    If you don't want to restructure the tree, then you can use the following steps:
    - First determine the middle value based on minimum and maximum
    - Then traverse the tree until you find the node closest to the projected middle.
  • glex911glex911 Member Posts: 11
    : : : : : : : : any one know a lot of this topic help me.....
    : : : : : : : :
    : : : : : : : Here's a good explanation: http://en.wikipedia.org/wiki/Binary_tree
    : : : : : : :
    : : : : : : : Basically a binary tree can be build using a single type of object,
    : : : : : : : which has two (or three) fields: left and right (and parent). The
    : : : : : : : parent field is optional, but it makes traversing the tree upward
    : : : : : : : quite easy.
    : : : : : :
    : : : : : : thanks pal.... it helps!
    : : : : : :
    : :
    : : finding mid and the max?
    : : : : :
    : : : : : i read it but dont read how to delete a node.
    : : : : :
    : : : : Here's how to insert and delete a node:
    : : : : http://en.wikipedia.org/wiki/Binary_search_tree
    : : :
    : : :
    : : :
    : : : nice thanks pal.
    : : :
    : :
    : :
    : Finding the maximum and minimum is quite simple:
    : Based on the text of the wikipedia:
    : - Maximum is the right-most node
    : - Maximum is the left-most node
    : If the tree is balanced, then the middle is always the root, but for
    : an unbalanced tree, it is easier to restructure it to a list.
    : If you don't want to restructure the tree, then you can use the
    : following steps:
    : - First determine the middle value based on minimum and maximum
    : - Then traverse the tree until you find the node closest to the
    : projected middle.






    - Maximum is the right-most node
    : - Maximum is the left-most node <-----left or right??????

    so you meant to say that we can make prog like this.. if(>right-most node>max)
    max = right-most node;
    System.out.println(max);

  • zibadianzibadian Member Posts: 6,349
    : : : : : : : : : any one know a lot of this topic help me.....
    : : : : : : : : :
    : : : : : : : : Here's a good explanation: http://en.wikipedia.org/wiki/Binary_tree
    : : : : : : : :
    : : : : : : : : Basically a binary tree can be build using a single type of object,
    : : : : : : : : which has two (or three) fields: left and right (and parent). The
    : : : : : : : : parent field is optional, but it makes traversing the tree upward
    : : : : : : : : quite easy.
    : : : : : : :
    : : : : : : : thanks pal.... it helps!
    : : : : : : :
    : : :
    : : : finding mid and the max?
    : : : : : :
    : : : : : : i read it but dont read how to delete a node.
    : : : : : :
    : : : : : Here's how to insert and delete a node:
    : : : : : http://en.wikipedia.org/wiki/Binary_search_tree
    : : : :
    : : : :
    : : : :
    : : : : nice thanks pal.
    : : : :
    : : :
    : : :
    : : Finding the maximum and minimum is quite simple:
    : : Based on the text of the wikipedia:
    : : - Maximum is the right-most node
    : : - Maximum is the left-most node
    : : If the tree is balanced, then the middle is always the root, but for
    : : an unbalanced tree, it is easier to restructure it to a list.
    : : If you don't want to restructure the tree, then you can use the
    : : following steps:
    : : - First determine the middle value based on minimum and maximum
    : : - Then traverse the tree until you find the node closest to the
    : : projected middle.
    :
    :
    :
    :
    :
    :
    : - Maximum is the right-most node
    : : - Maximum is the left-most node <-----left or right??????
    - Sorry, my mistake: minimum is the left most node.
    :
    : so you meant to say that we can make prog like this.. if(>right-most
    : node>max)
    : max = right-most node;
    : System.out.println(max);
    :
    :
    That's not necessary, because a binary tree already has the maximum value at the right. Thus this code gives the maximum of the tree:
    [code]
    current = root;
    while (current.right != null)
    current = current.right;
    System.out.println(current.value);
    [/code]
    The same for the minimum (change right with left).
    If you look at this
    http://en.wikipedia.org/wiki/Image:Binary_search_tree.svg
    and run the code, then you will end up at the 14 node.
«1
Sign In or Register to comment.