GATE Overflow - Recent questions tagged binary-tree
https://gateoverflow.in/tag/binary-tree
Powered by Question2AnswerBinary tree
https://gateoverflow.in/159872/binary-tree
In a binary tree, the time complexity of best upper and lower bound time required to get number of subtrees having exactly 8 nodes?DShttps://gateoverflow.in/159872/binary-treeSat, 14 Oct 2017 06:50:10 +0000GATE 1987#Binary Tree
https://gateoverflow.in/154126/gate-1987%23binary-tree
<p><a rel="nofollow" href="http://gateoverflow.in/2604/gate1995_1-17">http://gateoverflow.in/2604/gate1995_1-17</a> .What is the degree of a node in a tree? Is it same as a graph OR the number of children of that node?</p>Programminghttps://gateoverflow.in/154126/gate-1987%23binary-treeFri, 22 Sep 2017 05:15:01 +0000Binary Tree
https://gateoverflow.in/152728/binary-tree
How many numbers of binary tree can be created with 4 nodes which when traversed in post order gives the sequence D, C, B, A?<br />
<br />
1. 14<br />
<br />
2. 15<br />
<br />
3. 10<br />
<br />
4. 16<br />
<br />
Please Explain.<br />
<br />
Is there any formula?DShttps://gateoverflow.in/152728/binary-treeSat, 16 Sep 2017 16:25:38 +0000Trees
https://gateoverflow.in/148007/trees
Can somebody please list out the main advantages of B trees, B+ trees and Binary Search Trees over each other?Databaseshttps://gateoverflow.in/148007/treesMon, 28 Aug 2017 16:42:49 +0000binary tree
https://gateoverflow.in/146083/binary-tree
If a binary tree contains 1056 nodes the what is the height of binary tree??DShttps://gateoverflow.in/146083/binary-treeMon, 21 Aug 2017 12:19:57 +0000the gate book
https://gateoverflow.in/145174/the-gate-book
The no. of binary trees with 3 nodes which when traversed by post-order gives the sequence<br />
A, B, C is:<br />
(a) 3 (b) 9<br />
(c) 7 (d) 5DShttps://gateoverflow.in/145174/the-gate-bookFri, 18 Aug 2017 10:57:36 +0000Binary tree doubt
https://gateoverflow.in/142527/binary-tree-doubt
<p>Q Consider a complete Binary Tree <em>‘T’</em> with key of root node be <em>‘P’</em>. It is given that the left and right subtree of <em>‘P’</em> satisfies min-heap property. What is the time taken to convert the given tree <em>‘T’</em> to a max heap ?</p>
<p>1.O(log n)</p>
<p>2.O(n)</p>
<p>3. O(n log n)</p>
<p>4.Ο(n2)</p>Programminghttps://gateoverflow.in/142527/binary-tree-doubtTue, 08 Aug 2017 17:50:10 +0000Binary Tree DS
https://gateoverflow.in/142112/binary-tree-ds
How many distinct binary tree can be formed with three distinct keys?<br />
<br />
Please help me to find the correct answer?Programminghttps://gateoverflow.in/142112/binary-tree-dsSun, 06 Aug 2017 14:21:14 +0000Which of the following represents the number of labeled binary trees with ‘n’ node, which have same preorder ?
https://gateoverflow.in/141988/following-represents-number-labeled-binary-which-preorder
<ol>
<li><img alt="" src="http://www.wooe.in/dashboard/img/Uploads/tumbnails/untitled%20folder%20128/021-c.png"></li>
<li><img alt="" src="http://www.wooe.in/dashboard/img/Uploads/tumbnails/untitled%20folder%20128/021-b.png"></li>
<li><img alt="" src="http://www.wooe.in/dashboard/img/Uploads/tumbnails/untitled%20folder%20128/021-a.png"></li>
<li>Can not find out</li>
</ol>Programminghttps://gateoverflow.in/141988/following-represents-number-labeled-binary-which-preorderSun, 06 Aug 2017 03:28:33 +0000What does the following code do?
https://gateoverflow.in/135950/what-does-the-following-code-do
<pre>
<code>int A(struct node* node)
{
if (node==NULL)
return 0;
else
{
int lDepth = A(node->left);
int rDepth = A(node->right);
/* use the larger one */
if (lDepth > rDepth)
return(lDepth+1);
else
return(rDepth+1);
}
} </code></pre>Programminghttps://gateoverflow.in/135950/what-does-the-following-code-doTue, 04 Jul 2017 05:41:31 +0000Difference between finding Inorder Successor vs finding next using Inorder Traversal in BST
https://gateoverflow.in/134681/difference-between-finding-inorder-successor-finding-traversal
<h2> How is it possible that the time complexity of inorder traversal is O(n), because the time complexity of Inorder Successor in Binary Search Tree is O(log n), So the inorder traversal in BST for printing the numbers take O(n*logn) time for 'n' nodes???</h2>
<h3> </h3>Algorithmshttps://gateoverflow.in/134681/difference-between-finding-inorder-successor-finding-traversalSun, 25 Jun 2017 10:02:31 +0000the height of a binary tree
https://gateoverflow.in/132778/the-height-of-a-binary-tree
The height of a binary tree having 'i' nodes at level 'i' considering root to be at level 1 is ------. where 'n' is the total no of nodes in the tree.<br />
<br />
A. O(logn)<br />
<br />
B. O(n)<br />
<br />
C. O(ROOT(N))<br />
<br />
D. O(N2)Algorithmshttps://gateoverflow.in/132778/the-height-of-a-binary-treeMon, 12 Jun 2017 14:04:24 +0000ISRO2017-50
https://gateoverflow.in/128696/isro2017-50
<p><img alt="" src="http://gateoverflow.in/?qa=blob&qa_blobid=5662057041495426284"></p>
<p>If the post order traversal gives ab -cd * + then the label of the nodes 1,2,3.. will be</p>
<ol style="list-style-type:upper-alpha">
<li>+ , -, *, a,b,c,d</li>
<li>a, -,b,+,c,*,d</li>
<li>a,b,c,d,-,*,+</li>
<li>-,a,b,+,*,c,d</li>
</ol>DShttps://gateoverflow.in/128696/isro2017-50Sun, 07 May 2017 20:51:28 +0000Trees
https://gateoverflow.in/124007/trees
What is the difference between height and levels for a tree. What will be the value of height and level for root node and why?Algorithmshttps://gateoverflow.in/124007/treesTue, 04 Apr 2017 17:33:23 +0000internal path length of complete binary tree
https://gateoverflow.in/122452/internal-path-length-of-complete-binary-tree
can someone pls explain how is the internal path length of complete binary tree is O(n logn)? (if it is correct)Algorithmshttps://gateoverflow.in/122452/internal-path-length-of-complete-binary-treeFri, 24 Mar 2017 16:52:36 +0000madeeasy test series
https://gateoverflow.in/116654/madeeasy-test-series
<p><img alt="" src="http://gateoverflow.in/?qa=blob&qa_blobid=4151932699147893837"></p>Algorithmshttps://gateoverflow.in/116654/madeeasy-test-seriesMon, 06 Feb 2017 23:25:59 +0000MADE EASY TEST SERIES
https://gateoverflow.in/110994/made-easy-test-series
<p>Consider the following C program segment:
<br>
struct node</p>
<p><img alt="" src="http://gateoverflow.in/?qa=blob&qa_blobid=9951754205485313349"></p>
<p> </p>
<p>What is the output of above C program when it runs on a root node of a binary tree?</p>
<ul>
<li>prints nodes at K distance from root node.</li>
<li>print nodes of K<sup>th</sup> level of binary tree.</li>
<li>Both (a) and (b)</li>
<li>None of these</li>
</ul>DShttps://gateoverflow.in/110994/made-easy-test-seriesWed, 25 Jan 2017 17:04:34 +0000max-heap
https://gateoverflow.in/105582/max-heap
<p><img alt="" src="http://gateoverflow.in/?qa=blob&qa_blobid=9748494984370825096"></p>
<p>How come the answer is 8 I think it shoulb be 4.</p>Programminghttps://gateoverflow.in/105582/max-heapSun, 15 Jan 2017 00:16:47 +0000Tree BFS
https://gateoverflow.in/105129/tree-bfs
<pre class="prettyprint lang-c_cpp">
int func(Node root) {
int x = 0;
int y = 0;
queue Q;
Q.push(root);
while(!Q.empty()) {
Node u = Q.top();
Q.pop();
if(u->left == NULL && u->right == NULL) x++;
if(u->left != NULL) {
y++;
Q.push(u->left);
}
if(u->right != NULL) {
y++;
Q.push(u->right);
}
}
return x+y;
}</pre>
<p> </p>
<p>Above code segment is executed on the following rooted tree:</p>
<p> </p>
<p><img alt="" src="http://gateoverflow.in/?qa=blob&qa_blobid=15325516965057815059"></p>
<p> </p>
<p>What will be the output?</p>
<p> </p>Programminghttps://gateoverflow.in/105129/tree-bfsFri, 13 Jan 2017 19:51:15 +0000Tree DFS
https://gateoverflow.in/105107/tree-dfs
<pre class="prettyprint lang-c_cpp">
int func(Node root) {
if(root == NULL) return 0;
else if(root->left == NULL && root->right == NULL) return 2;
else return(3 + func(root->left) + func(root->right));
}</pre>
<p> </p>
<p>Above code is executed on the following rooted tree.</p>
<p> </p>
<p><img alt="" src="http://gateoverflow.in/?qa=blob&qa_blobid=11834642127606960890"></p>
<p>What will be the output?</p>Programminghttps://gateoverflow.in/105107/tree-dfsFri, 13 Jan 2017 19:27:36 +0000virtual-gate-2015 DS
https://gateoverflow.in/104595/virtual-gate-2015-ds
<p><img alt="" src="http://gateoverflow.in/?qa=blob&qa_blobid=3530696987581806199"></p>
<p>What is the correct answer?</p>DShttps://gateoverflow.in/104595/virtual-gate-2015-dsThu, 12 Jan 2017 19:51:36 +0000betweenB trees and B+ trees,which one is suited for random and which one is suited for sequential access??
https://gateoverflow.in/103997/betweenb-trees-which-suited-random-suited-sequential-access
between B trees and B+ trees,which one is suited for random and which one is suited for sequential access??<br />
<br />
please explainDatabaseshttps://gateoverflow.in/103997/betweenb-trees-which-suited-random-suited-sequential-accessWed, 11 Jan 2017 15:32:03 +0000common ancestors of two nodes in AVl tress
https://gateoverflow.in/94957/common-ancestors-of-two-nodes-in-avl-tress
can anyone define the procedure to find the common ancestor of any two given nodes in balanced BST..??DShttps://gateoverflow.in/94957/common-ancestors-of-two-nodes-in-avl-tressWed, 21 Dec 2016 12:42:20 +0000Linear Search: expected number of searches
https://gateoverflow.in/93184/linear-search-expected-number-of-searches
Given an array of 1,000,000 distinct integers you are going to perform 100,000 searches, one at a time, using the linear search algorithm. Each element you are searching for is in the array. What is the expected, total number of comparisons performed by the 100,000 linear searches?<br />
<br />
Please explain<br />
<br />
Given Ans: 5x10^10 + 5x10^4Algorithmshttps://gateoverflow.in/93184/linear-search-expected-number-of-searchesFri, 16 Dec 2016 01:52:56 +0000No of binary tree
https://gateoverflow.in/91320/no-of-binary-tree
number of distinct binary tree,that can be created by 5 nodes(distinct)Graph Theoryhttps://gateoverflow.in/91320/no-of-binary-treeSat, 10 Dec 2016 11:50:49 +0000trees
https://gateoverflow.in/91083/trees
<p><img alt="" src="http://gateoverflow.in/?qa=blob&qa_blobid=16041101576776754248"></p>DShttps://gateoverflow.in/91083/treesFri, 09 Dec 2016 15:50:40 +0000number of distinct binary search trees
https://gateoverflow.in/91078/number-of-distinct-binary-search-trees
<p><img alt="" src="http://gateoverflow.in/?qa=blob&qa_blobid=13120267025069148225"></p>
<p>The answer is given as 14.I calculated using Catalan number but the answer did not come as 14.</p>Programming & DShttps://gateoverflow.in/91078/number-of-distinct-binary-search-treesFri, 09 Dec 2016 15:41:46 +0000GATE1989-3-ixa
https://gateoverflow.in/87143/gate1989-3-ixa
<p>Answer the following:</p>
<p>Which one of the following statements (s) is/are FALSE?</p>
<ol style="list-style-type:upper-alpha">
<li>Overlaying is used to run a program, which is longer than the address space of the computer.</li>
<li>Optimal binary search tree construction can be performed efficiently by using dynamic programming.</li>
<li>Depth first search cannot be used to find connected components of a graph.</li>
<li>Given the prefix and postfix walls over a binary tree, the binary tree can be uniquely constructed.</li>
</ol>DShttps://gateoverflow.in/87143/gate1989-3-ixaSun, 27 Nov 2016 19:13:43 +0000Binary tree
https://gateoverflow.in/86944/binary-tree
<p><img alt="" src="http://gateoverflow.in/?qa=blob&qa_blobid=15466836056383660038"></p>
<p>What should be output for $n = 8$??</p>DShttps://gateoverflow.in/86944/binary-treeSun, 27 Nov 2016 11:04:08 +0000GATE1990-3-iv
https://gateoverflow.in/84828/gate1990-3-iv
<p>Choose the correct alternatives (More than one may be correct).</p>
<p>The total external path length, EPL, of a binary tree with $n$ external nodes is, $EPL= \sum_{w} Iw$, where $I_{w}$ is the path length of external node $w$),</p>
<ol style="list-style-type:upper-alpha">
<li>$\leq n^{2}$ always.</li>
<li>$\geq n \log_{2} n$ always.</li>
<li>Equal to $n^{2}$ always.</li>
<li>$O(n)$ for some special trees.</li>
</ol>DShttps://gateoverflow.in/84828/gate1990-3-ivTue, 22 Nov 2016 18:20:32 +0000Trees
https://gateoverflow.in/84704/trees
<p><img alt="" src="http://gateoverflow.in/?qa=blob&qa_blobid=5012420980834296042"></p>DShttps://gateoverflow.in/84704/treesTue, 22 Nov 2016 04:15:26 +0000Question Binary tree
https://gateoverflow.in/84454/question-binary-tree
<p><img alt="" src="http://gateoverflow.in/?qa=blob&qa_blobid=14403718204565799"></p>DShttps://gateoverflow.in/84454/question-binary-treeMon, 21 Nov 2016 07:43:54 +0000GATE1990-3-iii
https://gateoverflow.in/84060/gate1990-3-iii
<p>Choose the correct alternatives (More than one may be correct).</p>
<p>The number of rooted binary trees with $n$ nodes is,</p>
<ol style="list-style-type:upper-alpha">
<li>Equal to the number of ways of multiplying $(n+1)$ matriees.</li>
<li>Equal to the number of ways of arranging $n$ out of $2 n$ distinct elements.</li>
<li>Equal to $\frac{1}{(n+1)}\binom{2n}{n}$.</li>
<li>Equal to $n!$.</li>
</ol>DShttps://gateoverflow.in/84060/gate1990-3-iiiSat, 19 Nov 2016 15:38:37 +0000GATE1987-7b
https://gateoverflow.in/82427/gate1987-7b
<p>Construct a binary tree whose preorder traversal is</p>
<ul>
<li>K L N M P R Q S T</li>
</ul>
<p>and inorder traversal is</p>
<ul>
<li>N L K P R M S Q T</li>
</ul>DShttps://gateoverflow.in/82427/gate1987-7bTue, 15 Nov 2016 00:05:46 +0000GATE1987-2g
https://gateoverflow.in/80588/gate1987-2g
State whether the following statements are TRUE or FALSE:<br />
<br />
If the number of leaves in a tree is not a power of 2, then the tree is not a binary tree.DShttps://gateoverflow.in/80588/gate1987-2gWed, 09 Nov 2016 18:50:25 +0000GATE1987-2c
https://gateoverflow.in/80579/gate1987-2c
State whether the following statements are TRUE or FALSE:<br />
<br />
It is possible to construct a binary tree uniquely whose pre-order and post-order traversals are givenDShttps://gateoverflow.in/80579/gate1987-2cWed, 09 Nov 2016 18:36:01 +0000Binary Trees
https://gateoverflow.in/80340/binary-trees
I have seen that in some question height and deapth of binary tree are used interchangably. So, I request to say difference between height and deapth of a binary tree.Programminghttps://gateoverflow.in/80340/binary-treesTue, 08 Nov 2016 21:59:10 +0000Kerala PSC AP Exam
https://gateoverflow.in/77268/kerala-psc-ap-exam
IN a binary tree, the number of internal nodes of degree one is 5 and the number of internal nodes of degree 2 is 10. The number of leaf nodes in the binary tree is<br />
<br />
A) 15<br />
<br />
B) 11<br />
<br />
C) 12<br />
<br />
D) 10DShttps://gateoverflow.in/77268/kerala-psc-ap-examThu, 27 Oct 2016 22:24:40 +0000Kerala PSC AP Exam
https://gateoverflow.in/77258/kerala-psc-ap-exam
<p>In a binary tree, for every node the difference between the number of nodes in the left and right sub trees is atmost 2. If the height of the tree is h > 0 , then the minimum number of nodes in the tree is</p>
<p>A) 2 <sup>h-1</sup></p>
<p>B) 2<sup>h-1 </sup>+1</p>
<p>C) 2<sup>h</sup> - 1</p>
<p>D) 2<sup>h</sup></p>DShttps://gateoverflow.in/77258/kerala-psc-ap-examThu, 27 Oct 2016 22:07:42 +0000binary tree
https://gateoverflow.in/77029/binary-tree
<p><img alt="" src="http://gateoverflow.in/?qa=blob&qa_blobid=10819883219852282776"></p>Algorithmshttps://gateoverflow.in/77029/binary-treeWed, 26 Oct 2016 23:17:10 +0000Threaded tree
https://gateoverflow.in/71902/threaded-tree
<p><img alt="Loading Question" src="https://d2190hpfa85jkd.cloudfront.net/q/355eed909c80a76b4e58357a21803e2f.jpg"></p>Databaseshttps://gateoverflow.in/71902/threaded-treeWed, 05 Oct 2016 21:31:35 +0000A binary tree has 127 nodes. Which of the following is an invalid height for this tree ?
https://gateoverflow.in/65176/binary-tree-nodes-which-following-invalid-height-this-tree
<p>A binary tree has 127 nodes. Which of the following is an<strong> invalid height </strong>for this tree ?</p>
<p>$a). 16 $</p>
<p>$b). 6$</p>
<p>$c). 21$</p>
<p>$d). 43$</p>https://gateoverflow.in/65176/binary-tree-nodes-which-following-invalid-height-this-treeSun, 28 Aug 2016 04:25:32 +0000Binary Search Tree
https://gateoverflow.in/64412/binary-search-tree
Suppose we do not have a parent pointer in the nodes of a search tree, only left-child and right-child. Which of the following operations can be computed in time $O(\log n)$ for a balanced search tree?<br />
<br />
1- find, insert, delete, but not min, max, pred, succ<br />
2- find, insert, delete, min, max, but not pred, succ<br />
3- find, insert, delete, pred, succ but not min, max<br />
4- All of find, insert, delete, min, max, pred, succAlgorithmshttps://gateoverflow.in/64412/binary-search-treeTue, 23 Aug 2016 10:53:54 +0000#binary tree
https://gateoverflow.in/64086/%23binary-tree
what is te diffrence b/w hight, depth, level in binary tree and can i say level= height+1 if yes then prove itDShttps://gateoverflow.in/64086/%23binary-treeSun, 21 Aug 2016 11:12:59 +0000