Recent questions tagged binary-tree

56 56 votes
8 answers 8 answers
46.5k
46.5k views
A binary tree $T$ has $n$ leaf nodes. The number of nodes of degree $2$ in $T$ is$\log_2 n$$n-1$$n$$2^n$
46 46 votes
3 answers 3 answers
14.9k
14.9k views
A rooted tree with $12$ nodes has its nodes numbered $1$ to $12$ in pre-order. When the tree is traversed in post-order, the nodes are visited in the order $3, 5, 4, 2, 7...
25 25 votes
3 answers 3 answers
5.5k
5.5k views
Prove by the principal of mathematical induction that for any binary tree, in which every non-leaf node has $2$-descendants, the number of leaves in the tree is one more ...
30 30 votes
3 answers 3 answers
8.9k
8.9k views
A size-balanced binary tree is a binary tree in which for every node the difference between the number of nodes in the left and right subtree is at most $1$. The distance...
89 89 votes
14 answers 14 answers
31.0k
31.0k views
In a binary tree with $n$ nodes, every node has an odd number of descendants. Every node is considered to be its own descendant. What is the number of nodes in the tree ...
70 70 votes
4 answers 4 answers
20.3k
20.3k views
The height of a tree is defined as the number of edges on the longest path in the tree. The function shown in the pseudo-code below is invoked as height (root) to compute...
75 75 votes
14 answers 14 answers
48.9k
48.9k views
We are given a set of $n$ distinct elements and an unlabeled binary tree with $n$ nodes. In how many ways can we populate the tree with the given set so that it becomes a...
143 143 votes
17 answers 17 answers
42.0k
42.0k views
Consider a rooted n node binary tree represented using pointers. The best upper bound on the time required to determine the number of subtrees having exactly $4$ nodes is...
33 33 votes
2 answers 2 answers
7.2k
7.2k views
Draw the binary tree with node labels $\text{a, b, c, d, e, f and g}$ for which the inorder and postorder traversals result in the following sequences:Inorder: $\text{a f...
36 36 votes
4 answers 4 answers
14.2k
14.2k views
Consider the following C program segment where $\text{CellNode}$ represents a node in a binary tree:struct CellNode { struct CellNode *leftChild; int element; struct Cell...
24 24 votes
3 answers 3 answers
11.3k
11.3k views
The inorder and preorder traversal of a binary tree are$\text{d b e a f c g}$ and $\text{a b d e c f g}$, respectivelyThe postorder traversal of the binary tree is:$\text...
39 39 votes
4 answers 4 answers
41.0k
41.0k views
The maximum number of binary trees that can be formed with three unlabeled nodes is:$1$$5$$4$$3$
40 40 votes
7 answers 7 answers
33.0k
33.0k views
The height of a binary tree is the maximum number of edges in any root to leaf path. The maximum number of nodes in a binary tree of height $h$ is:$2^h -1$$2^{h-1} -1$$2^...
56 56 votes
3 answers 3 answers
14.2k
14.2k views
Consider the following C program segmentstruct CellNode{ struct CellNode *leftChild int element; struct CellNode *rightChild; }; int Dosomething (struct CellNode *ptr) { ...
42 42 votes
3 answers 3 answers
14.0k
14.0k views
Consider the label sequences obtained by the following pairs of traversals on a labeled binary tree. Which of these pairs identify a tree uniquely?preorder and postorderi...
102 102 votes
5 answers 5 answers
28.5k
28.5k views
A scheme for storing binary trees in an array $X$ is as follows. Indexing of $X$ starts at $1$ instead of $0$. the root is stored at $X $. For a node stored at $X[i]$, th...
30 30 votes
2 answers 2 answers
5.0k
5.0k views
Draw all binary trees having exactly three nodes labeled $A, B$ and $C$ on which preorder traversal gives the sequence $C, B, A$.
154 154 votes
10 answers 10 answers
39.2k
39.2k views
A weight-balanced tree is a binary tree in which for each node, the number of nodes in the left sub tree is at least half and at most twice the number of nodes in the rig...
73 73 votes
6 answers 6 answers
27.5k
27.5k views
Let LASTPOST, LASTIN and LASTPRE denote the last vertex visited in a postorder, inorder and preorder traversal respectively, of a complete binary tree. Which of the foll...
47 47 votes
11 answers 11 answers
18.4k
18.4k views
Consider the following nested representation of binary trees: $(X \ Y \ Z)$ indicates $Y$ and $Z$ are the left and right subtrees, respectively, of node $X$. Note that $Y...
31 31 votes
5 answers 5 answers
9.0k
9.0k views
Consider the binary tree in the figure below:What structure is represented by the binary tree?
60 60 votes
2 answers 2 answers
18.8k
18.8k views
The weighted external path length of the binary tree in figure is ______
27 27 votes
8 answers 8 answers
10.0k
10.0k views
If the binary tree in figure is traversed in inorder, then the order in which the nodes will be visited is ______