Talk:Binary tree

message: Isn't level and breadth search the same? (http://tekpool.wordpress.com/2006/11/04/binary-tree-traversal-breadth-first-aka-width-first-aka-level-order/) ¼
-- Yes, they are the same. We should not be discussing traversal inside Binary tree but instead just point to the Tree traversal article. -- Ryuunoshounen (talk) 18:39, 29 November 2013 (UTC)
thread_title:  level vs breadth first 

message: As far as I know, duplicates are allowed in binary trees. Should this be added to the article, or is it even relevant? Meonkeys 18:47, May 16, 2005 (UTC)
RSPeer: yes, a binary tree can have a right child and no left child. Node "5" in :Image:Binary_tree.png has a right child and no left child. Meonkeys
:Hmm, duplicates allowed. That would be good to mention - really I should have had duplicates in the diagram. I'll fix this sometime. Please be bold. Deco 08:50, 19 May 2005 (UTC)
thread_title:  duplicates 

message: Should we also include the formula for counting binary trees somewhere? This is used when you want to do stastical analysis of insertion and deletion of nodes in the tree.
Somehow I think the formula k = \frac1{2n+1}{2n+1 \choose n} should be mentioned somewhere.
Preferably with a reference to where the formula is derived. In the formula, k is the number of trees that has exactly n nodes. So for example there are 5 binary trees with 3 nodes. This is also related to the fact that you can write three parenthesis in 5 different ways on a line: ((())), (()()), (())(), ()(()), ()()().
Of course, imposing further structure on the tree (Red black trees, AVL trees etc) would also influence the likelyhood of a given tree appearing and prohibit some. Speaking of variants, we should perhaps add a little reference to red black trees, avl trees and n-ary trees (binary trees is a special case where n=2), as well as many other trees that are used as ways of structuring data.
salte 12:54, 14 December 2006 (UTC)
thread_title:  Counting binary trees 

message: The article so far seems to be only a discussion of implementation methods and operating rules. I have noticed no mention of advantages/disadvantages of using binary trees over more conventional programming structures.
Also, can someone provide some real world applications where a binary tree could be used to solve a problem more easily or efficiently than other methods?
* Binary trees are superior to for example linked lists to hold a collection of items. Also, because they are binary you generally have few tests before determining where to go after visiting a given node. For example if you visit a node A and you have determined that this is not the node you are looking for, you also often typically know if you should check the left or the right branch after when searching for a node. Looking through a set of n nodes will take an order of O(log(n)) time while in a linked list it is of the order O(n) and as log(n) < n (base is larger than 1) and for large n the difference is large you can gain much speed. For example I once had a program that used a linked list and it took a long time to run, I then aborted it after an hour when it was still not done, rewrote to use a binary tree and the program took 8 minutes to run before it completed. For example in C if you use strcmp(skey,nkey) to compare the search key with the node key you first check if the return value was 0 - if it was 0 it means the keys were equal and you have found the node, if the return value was negative it means the node key was later in the sort and so you check out the left branch. Thus, all the nodes on the right branch are already known to be too large and can be skipped in the search. If the return value was positive you know you can skip the left branch and only check the right branch for the same reason.
salte 14:12, 3 April 2007 (UTC)
thread_title:  Examples 

message: the degree of a node in a rooted tree is the number of children - the edge from its parent node does not count.
Charieshane 04:00, 7 March 2007 (UTC)
thread_title:  the degree of a node in a rooted tree 

message: Could this article be amended to mention that trees may be encoded as strings, by using parenthesis? In mathematics, binary trees are known as free magmas, and the encoding as a string is important for algebra e.g. for free objects, and also for the foundations of syntax. The string encoding is also used by lisp (programming language), scheme (programming language) and prolog. Should also mention that the standard names for navigating a binary tree are CAR and CDR. Also, the encoding at the bottom of the article is wrong; the internal node labels (cons) were left out.linas 02:37, 9 April 2007 (UTC)
thread_title:  car, cdr, and lots of parens? 

message: The diagram in this section is confusing because there are two distinct nodes labeled "G". Muddle-headed Wombat 18:04, 9 April 2007 (UTC)
thread_title:  Encoding n-ary trees as binary trees 

message: Is there a difference between the node of a graph and the vertices of a graph?  If not, wouldn't it be better to use just a single word throughout the article? Taemyr 19:49, 12 May 2007 (UTC)
thread_title:  Nodes/Vertices 

message: I think there is something wrong to say Pre-order, in-order, and post-order traversal are all special cases of this(depth-first traversal)
In-order and post-order traversals visit child nodes before visiting their parents, which breaks the caveat that it must be a child of a node we have already visited.  --71.159.61.221 03:00, 28 June 2007 (UTC)
thread_title: special cases of depth-first traversal

message: A lisp-style node can point to left and right nodes, but if it does then the node cannot store a value. This makes it fundamentally different to a binary tree (assuming a binary tree node must be able  to store a value). If so, then should the "encoding n-ary trees" section be moved/removed?
Also, the "combinatorics" section mentions "car" and "cdr" and talks about trees as (a b) where a and b are subtrees but not, say, (a x b) where x is the node value. --2007-07-20
:Actually cons-based data structures are binary trees, but they can only store data in leaves. Conventionally they almost always store data in each cons's left child and sublists in each cons's right child (which makes the tree a degenerate list). You can represent arbitrary trees as well: for example, using dotted cons notation, (((1 . 2) . 3) . (4 . 5)) could be a valid binary tree storing some numbers. This is somewhat uncommon but is used. Dcoetzee 08:20, 21 July 2007 (UTC)
thread_title:  Lisp-style structures are not binary trees 

message: :This is not true at all. Duplicates were included to illustrate that a general labelled binary tree can include duplicate labels, and they were placed out of order to illustrate that generally they don't require order. Dcoetzee 19:45, 10 August 2007 (UTC)
thread_title:  Graph 

message: The current definition,
Another way of defining binary trees is a recursive definition on directed graphs. A binary tree is either:
* A single vertex.
* A graph formed by taking two binary trees, adding a vertex, and adding an edge directed from the new vertex to the root of each binary tree.
makes the tree
   A
  /
 B
an invalid binary tree, as it cannot be formed by combining two smaller binary trees. Does anyone have a more correct definition than this? Zetawoof(ζ) 00:01, 17 September 2007 (UTC)
replies: text: The definition depends on whether or not you consider the leaves to contain values, or whether they're "null" leaves. The current definition is correct in the latter case, while to permit the definition you'd need something more complicated that's difficult to describe with a recursive definition. I prefer the more structural definition that it's just a directed acyclic graph of maximum degree 3. Dcoetzee 02:43, 17 September 2007 (UTC)
thread_title:  Definition in graph theory: glitch? 

message: Maybe we should mention that a complete binary tree is often referred to as a heap in computer science.  This seems relevant to me as the opening statement refers to computer science.  Though somewhat irrelevant it might also be useful to mention that complete trees can be implemented using an array as opposed to a linked structure which is mentioned in the other sections.  Only in the array implementation a parent n can reach it's children at with something like left = 2n + 1 and right = 2n + 2, assuming a 0 indexed array.  —Preceding unsigned comment added by Cldoyle (talk • contribs) 02:04, 12 January 2008 (UTC)
replies: text: Binary heaps are mentioned (and linked) in the introduction. Do note that a complete binary tree is not the same thing as a heap! The binary tree property (left < parent < right) is quite different from the heap property (parent < child). Zetawoof(ζ) 06:28, 12 January 2008 (UTC)

text: I completely agree with you,Zetawoof! Visame (talk) 17:35, 18 May 2008 (UTC)
thread_title:  Heaps? 

message: There are two definitions for almost complete binary trees which pretty much state the same thing. Should these be merged or should one be deleted? I think the lower one more clearly represents an almost complete binary tree.  —Preceding unsigned comment added by 99.225.178.225 (talk) 14:22, 14 April 2008 (UTC)
thread_title:  Repeated Definitions 

message: Types of binary trees
....
A balanced binary tree is where the depth of all the leaves differs by at most 1. Balanced trees have a predictable depth 
...
It shoukd be Balanced trees have a predictable height  —Preceding unsigned comment added by 83.43.153.47 (talk) 08:20, 29 November 2009 (UTC)
thread_title:  height instead depth 

message: Isn't the classical graph, pictured here, incorrect on the Binary tree article?
===Explanation===
The node labeled "2" (assumed to be a value of the node) has a greater value linked on the left, and a lesser value linked on the right.
However, the node labeled "7" has a lesser value (than 7) on the left, and a greater value on the right.
I looked up the Binary tree article to link from an article of mine on binary tree signatures which is proposing a project to detect randomness perturbed by determinant effects on randomness, as some algorithmically detectable deviation across multiple trees.  (This paragraph is a shameless plug I suppose. Contact me if interested in a joint paper.)
Hopefully I'm not totally mistaken about the incorrect graphic, and do as you will with my scratches here... Regards -DonEMitchell (computer programmer)
:I think you are thinking of binary search tree.  I agree that more emphasis should be given to this (although there is a small link at the top).  —Preceding unsigned comment added by 67.183.113.131 (talk) 03:42, 16 July 2010 (UTC)
thread_title:  Delete this if I'm silly, but... 

message: The node labeled "2" (assumed to be a value of the node) has a greater value linked on the left, and a lesser value linked on the right.
However, the node labeled "7" has a lesser value (than 7) on the left, and a greater value on the right.
I looked up the Binary tree article to link from an article of mine on binary tree signatures which is proposing a project to detect randomness perturbed by determinant effects on randomness, as some algorithmically detectable deviation across multiple trees.  (This paragraph is a shameless plug I suppose. Contact me if interested in a joint paper.)
Hopefully I'm not totally mistaken about the incorrect graphic, and do as you will with my scratches here... Regards -DonEMitchell (computer programmer)
:I think you are thinking of binary search tree.  I agree that more emphasis should be given to this (although there is a small link at the top).  —Preceding unsigned comment added by 67.183.113.131 (talk) 03:42, 16 July 2010 (UTC)
thread_title: Explanation

message: The article says "A (rooted) tree with only one node (the root) has a height of zero (or one[2]).", and similarly for the depth. Is this "or one" really correct? The linked external article doesn't mention neither depth nor height. Since I don't know this topic, I will not do the correction myself. --HelgeStenstrom (talk) 12:14, 1 November 2010 (UTC)
thread_title:  depth/height and broken external link 

message: I propose that whatever is of value in Deletion in binary tree should be merged with this article. Malleus Fatuorum 17:05, 26 November 2010 (UTC)
replies: text: Does the lack of feedback indicate agreement or apathy? Malleus Fatuorum 16:31, 12 December 2010 (UTC)

text: I added a section in Binary Tree for node deletion that includes most of the information in the article. Do we want to keep the block of code from Deletion in binary tree or just scrap the page? I found that the page in question also has at least one inaccuracy, "a binary tree is always sorted..." Chris857 (talk) 23:10, 17 December 2010 (UTC)
replies: text: I'd vote for scrapping the page. Malleus Fatuorum 23:31, 17 December 2010 (UTC)
replies: text: It's gone, with a redirect to Binary tree#Deletion. Chris857 (talk) 00:14, 18 December 2010 (UTC)
thread_title:  Merge discussion 

message: Is it possible to delete a node from a binary tree that has two children? I know that its children can't just be assigned to its parent, because then the tree would be ternary. I've seen that it is possible with a binary search tree.  Chris857 (talk) 04:13, 19 December 2010 (UTC)
thread_title:  Deletion of a node with two children 

message: I have been bold and removed a paragraph from  Binary tree#Ahnentafel list. I'll paste it here:
"A binary tree can also be represented in the form of array as well as adjacency linked list. In the case of array, each node(root,left,right) is simply placed in the index and there is no connection mentioned about the relationship between parents and children. However, in linked list representation we can find the relationship between parent and children. In array representation the nodes are accessed by calculating the index. This method is used in languages like FORTRAN which doesn't have dynamic memory allocation. We can't insert a new node into array implemented binary tree with ease, but this is easily done when using a binary tree implemented as linked list."
The reason for removal is that the information in it is already stated in the first paragraph and in a better way. If anyone disagrees, discuss. Silver hr (talk) 21:33, 27 January 2011 (UTC)
thread_title:  Removed redundant paragraph from section Ahnentafel list 

message: * There was a link to the Tango tree article, but this section is not about algorithmic developments; this would be more appropriate in the template.
* there was a repetition here of Strictly Binary Tree, which was already defined earlier in the list.
LandruBek (talk) 19:42, 28 June 2011 (UTC)
thread_title:  Removed two sentences from section "Types of Binary Trees" 

message: Shouldn't this article have one of those info boxes summarizing the time complexity of insert/remove/lookup operations?
See
http://en.wikipedia.org/wiki/AVL_tree
Dj0nes (talk) 17:19, 6 January 2012 (UTC)
thread_title:  Info box 

message: This page has a mixture of content.  Some is about the data structure and some is about the mathematical properties of that data structure.  I believe a lot of the math should be split into a separate page and connected to graph theory.  (FYI, I've both taught data structures and done research in graph theory.)
Apparently I tried this once upon a time, and it got rolled back.  Checkout the change by mdnahas on 2009-12-30T22:24:21+00:00  — Preceding unsigned comment added by Mdnahas (talk • contribs) 21:40, 15 February 2013 (UTC)
thread_title:  Need to separate graph theory from the data structure 

message: The definition seems to be that of a non-empty binary tree, so - if so - why not just say so? 
68.183.92.186 (talk) 21:51, 13 May 2014 (UTC)
replies: text: The catch is that rooted binary tree, which even had its own little (but very confusing) article until recently, is often not defined the by people that use the phrase and they don't bother to define some (unrooted) binary tree either. The few (reputable) sources that do define it, define it the same way as binary tree, e.g. . I did find one source explicitly saying these are normally the same concept, so I've added that. JMP EAX (talk) 20:57, 27 July 2014 (UTC)
thread_title:  rooted binary tree  

message: It's actually a really confusingly written book, as far as binary trees are concerned. I'm not surprised that whoever used that as ref was unable to write a correct recursive definition of binary trees. Here's what the book has as def:
DEFINITION 4.1.1 A binary tree T consists of a set of nodes that is either empty or has the following 
properties: 
# One of the nodes, say R, is designated the root node. 
# The remaining nodes (if any) are partitioned into two disjoint subsets, called the left subtree and the right subtree, respectively, each of which is a binary tree. 
It's hard to think of a more unclear way to say that. It's clear that whoever red that got confused into (recursively) defining binary tree as just full binary tree did so because he missed the empty set being binary tree, which is actually one of the recursion branches in the above def despite not being numbered, while the "1"-numbered clause there is just a red herring as far as the recursion is concerned. JMP EAX (talk) 03:35, 26 July 2014 (UTC)
thread_title:  Removed the Berman & Paul ref 

message: The obvious thing that's needed to make that formal is a partial mapping from left/right labels to outgoing edges from each node, but I wasn't able find a single source to say that explicitly. JMP EAX (talk)
: Here's a mathematician who almost managed to give a working definition in terms of graph theory. Anany Levitin's (he is actually a math guy transplanted to CS) "Introduction to the Design and Analysis of Algorithms" 3rd ed., p.33: "A binary tree can be defined as an ordered tree [which is defined as rooted] in which every vertex has no more than two children and each child is designated as either a left child or a right child of its parent; a binary tree may also be empty." But that doesn't prevent you from labeling both children of a node as "left". Which is why you need a partial function. JMP EAX (talk) 01:58, 28 July 2014 (UTC)
thread_title:  Aho et al.'s observation 

message: The def of "full" binary tree here doesn't match the common one in most textbooks, which define full as all leaves being on the same level. That section and the terminology throughout the article needs a fair bit of rework. JMP EAX (talk) 03:18, 28 July 2014 (UTC)
replies: text: I think NIST notes that discrepancy in definitions in other texts that they found and it is probably better to follow NIST. 135.180.116.147 (talk) 15:50, 19 August 2020 (UTC)
thread_title:  Full binary tree etc. 

message: If the goal of this article was to hide an essentially simple subject behind a cloud of confusing waffle then it has succeeded brilliantly. In my opinion the introductory paragraph beginning "from a graph theory perspective..." could be deleted entirely and it wouldn't subtract an iota from the useful content of the article. I mean, waffling on about the original meaning of terms I never even heard of in 30 years as a programmer... why?  — Preceding unsigned comment added by 82.68.15.142 (talk) 14:52, 12 September 2014 (UTC)
thread_title:  Truly awful writing 

message: I have to agree with the previous poster, this article is fairly typical of maths, engineering and technology/medicine articles in Wikipedia. Written by the "experts" for the "experts", with expert not meaning having communication skills in anyway. Binary trees are one of the simplest structures in the universe. How can this article be SO full of waffle that I am scratching my head with each line wondering what I must have missed. It neesds a serious clean up. Start simple, get more complex as you go on if necessary. The first paragraph shoudl not be maths shorthand. How does that help anybody?
Communicate people! That is what an encyclopedia is for. Much appreciation to anybody who can clean this article up. It really needs it.
 Thank you for your suggestion. When you believe an article needs improvement, please feel free to make those changes.  Wikipedia is a wiki, so anyone can edit almost any article by simply following the edit this page link at the top. The Wikipedia community encourages you to be bold in updating pages. Don't worry too much about making honest mistakes—they're likely to be found and corrected quickly. If you're not sure how editing works, check out how to edit a page, or use the sandbox to try out your editing skills.  New contributors are always welcome. You don't even need to log in (although there are many reasons why you might want to). 
--DavidCary (talk) 03:34, 5 June 2015 (UTC)
thread_title:  Really truly awful writing 

message: In Binary_tree#Types_of_binary_trees "Physicists define a binary tree to mean a full binary tree."  The source isn't web so I can't check.  Is this a typo?  I'm not a physicist but I can't imagine what physicists would use the concept of a binary tree for, and physics/physicists aren't mentioned anywhere else in the article.  --Padenton (talk) 16:55, 10 March 2015 (UTC)
thread_title:  Physicists? 

message: I removed the following sentences from the lead because they addressed a subtlety that is already addressed in the section on defining a binary tree "Using graph theory concepts". The original is preserved here in case someone wants to revert this deletion. If you do the revert, can you also please clean up the English in the mentions of k-ary trees?
:There is however a subtle difference between the binary tree data structure as defined here and the notions from graph theory or as K-ary tree is usually defined. As defined here, a binary tree node having a left child but no right child is not the same as a node having a right child but no left child, whereas an ordered/plane tree (or arborescence) from graph theory cannot tell these cases apart, and neither does k-ary as usually understood as using a list of children. An actual generalization of binary tree would have to discern, for example, a case like having a first and third, but no second child; the trie data structure is actually the more appropriate generalization in this respect.
--DavidHolmes0 (talk) 16:23, 2 July 2015 (UTC)
thread_title:  removed subtlety from lead 

message: Hello fellow Wikipedians,
I have just modified  on Binary tree. Please take a moment to review my edit. If you have any questions, or need the bot to ignore the links, or the page altogether, please visit this simple FaQ for additional information. I made the following changes:
*Added archive https://web.archive.org/web/20101221085950/http://xw2k.nist.gov:80/dads/ to http://xw2k.nist.gov/dads/
When you have finished reviewing my changes, please set the checked parameter below to true or failed to let others know (documentation at ).
Cheers.—InternetArchiveBot (Report bug) 19:38, 2 November 2016 (UTC)
thread_title:  External links modified 

message: This would be a salient question I reckon. Maybe should have its own section.  — Preceding unsigned comment added by 85.76.151.104 (talk) 13:20, 3 May 2022 (UTC)
thread_title:  Are binary trees and R-trees reversible (save the NON-operator) or non-reversible 

message: Is there a name for algorithms and trees that maintain balancing property, but are not search trees (i.e. order of nodes do not matter), but tree is used for some aggregation of subtrees instead. (i.e. max value). These have interesting applications, but because they do not need to be ordered, might have way easier balancing strategies than BST.
81.6.34.169 (talk) 23:00, 14 April 2024 (UTC)
thread_title:  Balanced / self-balancing binary tree (not BST)