Why the tree is not a binary tree? - data-structures

I am a beginner in the field of data structures, I am studying binary trees and in my textbook there's a tree which is not a binary tree but I am not able to make out why the tree is not a binary tree because every node in the tree has atmost two children.
According to Wikipedia definition of binary tree is "In computer science, a binary tree is a treedata structure in which each node has at most two children, which are referred to as the left child and the right child."
The tree in the picture seems to satisfy the condition as mentioned in the definition of binary tree.
I want an explanation for why the tree is not a binary tree?

This is not even a tree, let alone binary tree. Node I has two parents which violates the tree property.

I got the answer, This not even a tree because a tree is connected acyclic graph also a binary tree is a finite set of elements that is either empty or is partitioned into three disjoint subsets. The first subset contains a single element called the root of the tree. The other two subsets are themselves binary trees called the left and right subtrees of the original tree.
Here the word disjoint answers the problem.

It's not a binary tree because of node I
This can be ABEI or ACFI
This would mean the node can be represented by 2 binary numbers which is incorrect
Each node has either 0 or 1 parents. 0 in the case of the root node. 1 otherwise. I has 2 parents E and F

Related

How to make Full Binary Tree with 6 nodes?

I know well about Full Binary Tree and Complete Binary Tree. But unable to make Full binary tree with only 6 nodes.
The answer is No. You can't make a Full binary tree with just 6 nodes. As the definition in the Wikipedia says:
A full binary tree (sometimes referred to as a proper or plane
binary tree) is a tree in which every node has either 0 or 2
children. Another way of defining a full binary tree is a recursive
definition. A full binary tree is either:
A single vertex.
A tree whose root node has two subtrees, both of which are full binary trees.
Another interesting property I noticed is that, the number of nodes required to make a full binary tree will always be odd.
Another way to see that a full binary tree has an odd number of nodes:
Starting with the definition of a full binary tree (Wikipedia):
a tree in which every node has either 0 or 2 children.
This means that the total number of child nodes is even (0+2+2+0+...+2 is always even). There is only one node that is not a child of another, which is the root. So considering that node as well, the total becomes odd.
By consequence there is no full binary tree with 6 nodes.
Elaborating on #vivek_23's answer, this is, unfortunately, not possible. There's a beautiful theorem that says the following:
Theorem: Any full binary tree has 2L - 1 nodes, where L is the number of leaf nodes in the tree.
The intuition behind this theorem is actually pretty simple. Imagine you take a complete binary tree and delete all the internal nodes from it. You now have a forest of L single-node full binary trees, one for each leaf. Now, add the internal nodes back one at a time. Each time you do, you'll be taking two different trees in the forest and combining them into a single tree, which decreases the number of trees in the forest by one. This means that you have to have exactly L - 1 internal nodes, since if you had any fewer you wouldn't be able to join together all the trees in the forest, and if you had any more you'd run out of trees to combine.
The fact that there are 2L - 1 total nodes in a full binary tree means that the number of nodes in a full binary tree is always odd, so you can't create a full binary tree with 6 nodes. However, you can create a full binary tree with any number of odd nodes - can you figure out how to prove that?
Hope this helps!

What is the difference between ordered tree and rooted tree? - An example

I know the definition of these two types of trees. However, I cannot understand their structures. Could you give me an example ?
A rooted Tree has only ONE Element which is considerd as root element.
In the examples below the root element is green and the data structure is represented in form of a binary tree with two child elements.
An Ordered Binary Tree is a form of rooted tree with a specific order.
Started from the root element the smaller number is on the left side and the higher number on the right side.
Ordered Binary Tree
An Unordered Binary Tree on the other side has no specific order of the elements.
Unordered Root Tree
The structure of an unordered tree looks like follows,
As can be seen in the above figure, the root of the tree is node A, but its children are not ordered from left to right or in any particular order. However, we can re-draw the tree as follows, in order to make it an ordered rooted tree.
An ordered tree can be either a binary tree or else a general tree. The binary nature of a tree and the ordered nature are two separate concepts. The overall idea is, a rooted tree is not an ordered rooted tree unless it is depicted according to a particular order or some additional textual information is given to notify the order.

Skewed Trees relation to Binary Search Tree

I know what Binary search tree is and I know how they work. But what does it take for it to become a skewed tree? What I mean is, do all nodes have to go on one side? or is there any other combination?
Having a tree in this shape (see below) is the only way to make it a skewed tree? If not, what are other possible skewed trees?
Skewed tree example:
Also, I searched but couldn't find a good solid definition of a skewed tree. Does anyone have a good definition?
Figured out a skewed Tree is the worst case of a tree.
`
The number of permutations of 1, 2, ... n = n!
The number of BST Shapes: (1/n+1)(2n!/n!n!)
The number of skewed trees of 1, 2, ....n = 2^(n-1)
`
Here is an example I was shown:
http://i61.tinypic.com/4gji9u.png
A good definition for a skew tree is a binary tree such that all the nodes except one have one and only one child. (The remaining node has no children.) Another good definition is a binary tree of n nodes such that its depth is n-1.
A binary tree, which is dominated solely by left child nodes or right child nodes, is called a skewed binary tree, more specifically left skewed binary tree, or right skewed binary tree.

Difference between ordered and unordered (rooted) trees

I am reading algorithms by Robert Sedwick. Some definitions from the book are shown below.
A tree (also an ordered tree) is a node (called the root) connected to
a sequence of disjoint trees. Such a sequence is called a forest.
A rooted tree (or unordered tree) is a node (called the root)
connected to a multiset of rooted trees. (such a multiset is called an
unordered forest.
My questions on the above text are
I am having difficutlty in understanding above defintions. Can any one please explain with examples.
What does author mean by disjoint trees?
What does author mean by multiset rooted trees?
Thanks for your time and help
A tree by this definition is more or less what we normally understand by tree: a node connected to an ordered sequence of (sub)trees. It's a recursive definition: if the sequence is empty, the node is called leaf, and if not, each of the tree in the sequence is also "a node connected to an ordered sequence of (sub)trees."
By disjoint the author means that the subtrees don't have nodes in common.
The definition means that the subtrees of a rooted tree are not in a particular order and that they may be repeated. A multiset is kind of like a set that allows multiples.
An ordered tree (a "tree" of the first definition) has the subtrees in a particular order, and the subtree sequence cannot contain the same tree twice, because the subtrees must be disjoint. A rooted tree does not have these restrictions; by this definition a root might have a subtree twice, in a structure that resembles a cycle.
I don't have Sedwick's book to check if or why this definition makes sense; a more common definition or rooted tree would use a normal set for subtrees, rather than a multiset. Perhaps the intention is to allow multiple links between a node and its children while disallowing other kinds of cycles, such as links between siblings and cousins.

Special Binary Tree

What is the name of the binary tree (or the family of the binary
trees), that is balanced, and has the minimum number of nodes
possible for its height?
Well this is special kind of tree not the AVL tree.
if the binary tree is balanced then, it height is a function of its nodes (n). height = log2n. so a balanced tree don't have a range of heights.
The minimum number of nodes a completely balanced binary tree can have for height d is 2^(d-1)+1. As far as i know this type doesn't have a name.
The maximal number of nodes is 2^d. This is called a complete tree. All layers are completely full and each node has either 2 or zero childern(implied).
Red-black tree?
Any one from http://en.wikipedia.org/wiki/Self-balancing_binary_search_tree#Implementations?
The name of the binary tree (or the family of the binary trees), that has the minimum number of nodes possible for its height is a linked list :D

Resources