GATE FORUM - Recent questions and answers in trees, binary search trees, binary heaps
http://gateforum.org//qa/computer-science-information-technology/data-structures/trees-binary-search-trees-binary-heaps
Powered by Question2AnswerAnswered: worst case time complexity for search, insert and delete operations in a Binary Search Tree
http://gateforum.org//719/worst-case-time-complexity-for-search-insert-and-delete-operations-in-a-binary-search-tree?show=2353#a2353
o(n) for alltrees, binary search trees, binary heapshttp://gateforum.org//719/worst-case-time-complexity-for-search-insert-and-delete-operations-in-a-binary-search-tree?show=2353#a2353Thu, 05 Jan 2017 10:38:48 +0000Answered: condition is sufficient to detect cycle in a directed graph
http://gateforum.org//903/condition-is-sufficient-to-detect-cycle-in-a-directed-graph?show=904#a904
<table><tbody><tr><td><p>There is an edge from currently being visited node to an ancestor of currently visited node in DFS forest.</p></td></tr></tbody></table>trees, binary search trees, binary heapshttp://gateforum.org//903/condition-is-sufficient-to-detect-cycle-in-a-directed-graph?show=904#a904Fri, 19 Feb 2016 16:45:32 +0000Answered: undirected graph depth first traversal DFS
http://gateforum.org//901/undirected-graph-depth-first-traversal-dfs?show=902#a902
If {u,v} is not an edge in G then u is a leaf in Ttrees, binary search trees, binary heapshttp://gateforum.org//901/undirected-graph-depth-first-traversal-dfs?show=902#a902Fri, 19 Feb 2016 16:44:09 +0000The height of the tree
http://gateforum.org//794/the-height-of-the-tree
<p>Consider the following C program segment</p><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td><p>struct CellNode</p><p>{</p><p> struct CelINode *leftchild;</p><p> int element;</p><p> struct CelINode *rightChild;</p><p>}</p><p></p><p>int Dosomething(struct CelINode *ptr)</p><p>{</p><p> int value = 0;</p><p> if (ptr != NULL)</p><p> {</p><p> if (ptr->leftChild != NULL)</p><p> value = 1 + DoSomething(ptr->leftChild);</p><p> if (ptr->rightChild != NULL)</p><p> value = max(value, 1 + DoSomething(ptr->rightChild));</p><p> }</p><p> return (value);</p><p>}</p></td></tr></tbody></table><p>The value returned by the function DoSomething when a pointer to the root of a non-empty tree is passed as argument is</p><table><tbody><tr><td><p>A</p></td><td><p>The number of leaf nodes in the tree</p></td></tr><tr><td><p>B</p></td><td><p>The number of nodes in the tree</p></td></tr><tr><td><p>C</p></td><td><p>The number of internal nodes in the tree</p></td></tr><tr><td><p>D</p></td><td><p>The height of the tree</p></td></tr></tbody></table>trees, binary search trees, binary heapshttp://gateforum.org//794/the-height-of-the-treeThu, 18 Feb 2016 20:58:09 +0000Answered: self-adjusting or self-balancing Binary Search Tree
http://gateforum.org//734/self-adjusting-or-self-balancing-binary-search-tree?show=735#a735
D<br />
<br />
All of the abovetrees, binary search trees, binary heapshttp://gateforum.org//734/self-adjusting-or-self-balancing-binary-search-tree?show=735#a735Thu, 18 Feb 2016 19:58:55 +0000Answered: number of ways in which the numbers can be inserted in an empty binary search tree
http://gateforum.org//732/number-of-ways-in-which-the-numbers-can-be-inserted-in-an-empty-binary-search-tree?show=733#a733
<p>To get height 6, we need to put either 1 or 7 at root. So count can be written as T(n) = 2*T(n-1) with T(1) = 1</p><pre> 7
/
[1..6]
1
\
[2..7] </pre><p>Therefore count is 2<sup>6</sup> = 64</p>trees, binary search trees, binary heapshttp://gateforum.org//732/number-of-ways-in-which-the-numbers-can-be-inserted-in-an-empty-binary-search-tree?show=733#a733Thu, 18 Feb 2016 19:57:40 +0000worst-case complexities of insertion and deletion of a key in a binary search tree
http://gateforum.org//731/worst-case-complexities-of-insertion-and-deletion-of-a-key-in-a-binary-search-tree
worst-case complexities of insertion and deletion of a key in a binary search tree<br />
<br />
The time taken by search, insert and delete on a BST is always proportional to height of BST. Height may become O(n) in worst case.trees, binary search trees, binary heapshttp://gateforum.org//731/worst-case-complexities-of-insertion-and-deletion-of-a-key-in-a-binary-search-treeThu, 18 Feb 2016 19:56:34 +0000Answered: traversals is sufficient to construct BST from given traversals 1) Inorder 2) Preorder 3) Postorder
http://gateforum.org//729/traversals-is-sufficient-to-construct-bst-from-given-traversals-inorder-preorder-3-postorder?show=730#a730
B<br />
<br />
Either 2 or 3 is sufficienttrees, binary search trees, binary heapshttp://gateforum.org//729/traversals-is-sufficient-to-construct-bst-from-given-traversals-inorder-preorder-3-postorder?show=730#a730Thu, 18 Feb 2016 19:55:27 +0000Answered: preorder traversal sequence of a binary search tree
http://gateforum.org//727/preorder-traversal-sequence-of-a-binary-search-tree?show=728#a728
D<br />
<br />
15, 10, 23, 25, 20, 35, 42, 39, 30trees, binary search trees, binary heapshttp://gateforum.org//727/preorder-traversal-sequence-of-a-binary-search-tree?show=728#a728Thu, 18 Feb 2016 19:54:28 +0000Answered: traversal outputs the data in sorted order in a BST
http://gateforum.org//725/traversal-outputs-the-data-in-sorted-order-in-a-bst?show=726#a726
Inorder traversal of a BST outputs data in sorted ordertrees, binary search trees, binary heapshttp://gateforum.org//725/traversal-outputs-the-data-in-sorted-order-in-a-bst?show=726#a726Thu, 18 Feb 2016 19:52:20 +0000Answered: distinct binary search trees can be created distinct keys
http://gateforum.org//723/distinct-binary-search-trees-can-be-created-distinct-keys?show=724#a724
<p>B</p><p>14</p><p><span style="font-size:18px">No. of BST= <sup>2n</sup>C<sub>n</sub>/(n+1) </span></p><p><span style="font-size:18px">therefore <sup>8</sup>C<sub>4</sub>/5 =14 option b</span></p><p></p>trees, binary search trees, binary heapshttp://gateforum.org//723/distinct-binary-search-trees-can-be-created-distinct-keys?show=724#a724Thu, 18 Feb 2016 19:50:59 +0000Answered: delete operation of BST inorder successor (or predecessor)
http://gateforum.org//721/delete-operation-of-bst-inorder-successor-or-predecessor?show=722#a722
B<br />
<br />
Inorder successor is always either a leaf node or a node with empty left childtrees, binary search trees, binary heapshttp://gateforum.org//721/delete-operation-of-bst-inorder-successor-or-predecessor?show=722#a722Thu, 18 Feb 2016 19:45:22 +0000Answered: Breadth First Search (BFS) is started on a binary tree beginning from the root vertex
http://gateforum.org//717/breadth-first-search-bfs-is-started-on-a-binary-tree-beginning-from-the-root-vertex?show=718#a718
31 for given distance 4trees, binary search trees, binary heapshttp://gateforum.org//717/breadth-first-search-bfs-is-started-on-a-binary-tree-beginning-from-the-root-vertex?show=718#a718Thu, 18 Feb 2016 19:41:43 +0000Answered: Postorder traversal of a given binary search tree
http://gateforum.org//715/postorder-traversal-of-a-given-binary-search-tree?show=716#a716
A<br />
<br />
9, 10, 15, 22, 23, 25, 27, 29, 40, 50, 60, 95trees, binary search trees, binary heapshttp://gateforum.org//715/postorder-traversal-of-a-given-binary-search-tree?show=716#a716Thu, 18 Feb 2016 19:39:12 +0000Answered: maximum number of binary trees that can be formed with three unlabeled nodes
http://gateforum.org//713/maximum-number-of-binary-trees-that-can-be-formed-with-three-unlabeled-nodes?show=714#a714
<p>all possible unlabeled binary trees</p><pre> O
/ \
O O
(i)
O
/
O
/
O
(ii)
O
/
O
\
O
(iii)
O
\
O
\
O
(iv)
O
\
O
/
O
(v)</pre>trees, binary search trees, binary heapshttp://gateforum.org//713/maximum-number-of-binary-trees-that-can-be-formed-with-three-unlabeled-nodes?show=714#a714Thu, 18 Feb 2016 19:36:12 +0000