You are on page 1of 1

Q.List the difference between a binary tree and a tree Any general tree can be represented as a binary tree.

The theory is to treat the left link of each node as the link to the node's first child and to treat the right link as the link to the node's next sibling. This technique requires the same number of nodes and uses only the two links that are part of the standard binary tree. Additional pointers can be stored to improve the performance of a general tree. Determining if a node is a child of another node is trivial if nodes contain a parent link. Removing a child from a parent does not require iteration through its children if you use next and previous sibling pointers. If you further make the sibling list circular, you can avoid most null pointers. Another common technique is to place a sentinel as a child for each node. This eliminates the need to modify the parent when adding or removing children. The root of a tree is usually a sentinel when you follow this technique. Combining sentinels with the double-linked circular sibling list eliminates all special cases when adding or removing nodes OR Let's start with graphs. A graph is a collection of nodes and edges. If you drew a bunch of dots on paper and drew lines between them arbitrarily, you'd have drawn a graph. A directed acyclic graph is a graph with some restrictions: all the edges are directed (point from one node to another, but not both ways) and the edges don't form cycles (you can't go around in circles forever). A tree, in turn, is a directed acyclic graph with the condition that every node is accessible from a single root. This means that every node has a "parent" node and 0 or more "child" nodes, except for the root node which has no parent. A binary tree is a tree with one more restriction: no node may have more than 2 children. More specific than binary trees are balanced binary trees, and more specific than that, heaps.

You might also like