Tree Data Structures questions — page 3 of 3

Q22

GATE CS 2015 CS-2Tree Data StructuresMCQ1 mark−1/3 if wrong
Consider a complete binary tree where the left and the right subtrees of the root are max-heaps. The lower bound for the number of operations to convert the tree to a heap is
Show answer without attempting

Answer: A

Q23

GATE CS 2015 CS-2Tree Data StructuresNAT1 mark
A binary tree T has 20 leaves. The number of nodes in T having two children is _______.
Show answer without attempting

Answer: 19

Q12

GATE CS 2014 CS-2Tree Data StructuresMCQ1 mark−1/3 if wrong
A priority queue is implemented as a Max-Heap. Initially, it has 5 elements. The level-order traversal of the heap is: 10, 8, 5, 3, 2. Two new elements 1 and 7 are inserted into the heap in that order. The level-order traversal of the heap after the insertion of the elements is:
Show answer without attempting

Answer: A

Q39

GATE CS 2014 CS-2Tree Data StructuresNAT2 marks
Consider the expression tree shown. Each leaf represents a numerical value, which can either be 0 or 1. Over all possible choices of the values at the leaves, the maximum possible value of the expression represented by the tree is ___.
Question figure
Show answer without attempting

Answer: 6

Q12

GATE CS 2014 CS-3Tree Data StructuresMCQ1 mark−1/3 if wrong
Consider the following rooted tree with the vertex labeled P as the root:

The order in which the nodes are visited during an in-order traversal of the tree is
Question figure
Show answer without attempting

Answer: A

Q39

GATE CS 2014 CS-3Tree Data StructuresNAT2 marks
Suppose we have a balanced binary search tree TT holding nn numbers. We are given two numbers LL and HH and wish to sum up all the numbers in TT that lie between LL and HH. Suppose there are mm such numbers in TT. If the tightest upper bound on the time to compute the sum is O(nalog⁡bn+mclog⁡dn)O(n^a \log^b n + m^c \log^d n), the value of a+10b+100c+1000da + 10b + 100c + 1000d is ____.
Show answer without attempting

Answer: 110

Q41

GATE CS 2014 CS-3Tree Data StructuresMCQ2 marks−2/3 if wrong
Consider the pseudocode given below. The function DoSomething() takes as argument a pointer to the root of an arbitrary tree represented by the leftMostChild-rightSibling representation. Each node of the tree is of type treeNode.
typedef struct treeNode* treeptr;
struct treeNode
{
  treeptr leftMostChild, rightSibling;
};
int DoSomething (treeptr tree)
{
  int value=0;
  if (tree != NULL) {
    if (tree->leftMostChild == NULL)
      value = 1;
    else
      value = DoSomething(tree->leftMostChild);
    value = value + DoSomething(tree->rightSibling);
  }
  return(value);
}
When the pointer to the root of a tree is passed as the argument to DoSomething, the value returned by the function corresponds to the
Show answer without attempting

Answer: D

Q12

GATE CS 2014 CS-1Tree Data StructuresNAT1 mark
Consider a rooted nn 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 O(nalog⁡bn)O(n^a \log^b n). Then the value of a+10ba + 10b is ___________.
Show answer without attempting

Answer: 1

Q7

GATE CS 2013 CSTree Data StructuresMCQ1 mark−1/3 if wrong
Which one of the following is the tightest upper bound that represents the time complexity of inserting an object into a binary search tree of nn nodes?
Show answer without attempting

Answer: C

Q43

GATE CS 2013 CSTree Data StructuresMCQ2 marks−2/3 if wrong
The preorder traversal sequence of a binary search tree is 30, 20, 10, 15, 25, 23, 39, 35, 42. Which one of the following is the postorder traversal sequence of the same tree?
Show answer without attempting

Answer: D

Q5

GATE CS 2012 CSTree Data StructuresMCQ1 mark−1/3 if wrong
The worst case running time to search for an element in a balanced binary search tree with n2nn2^n elements is
Show answer without attempting

Answer: C

Q47

GATE CS 2012 CSTree Data StructuresMCQ2 marks−2/3 if wrong
The height of a tree is defined as the number of edges on the longest path in the tree. The function shown in the pseudocode below is invoked as height(root) to compute the height of a binary tree rooted at the tree pointer root.
int height (treeptr n)
{ if (n == NULL) return -1;
  if (n -> left == NULL)
      if (n -> right == NULL) return 0;

      else return [B1] ;                // Box 1

  else { h1 = height (n -> left);
         if (n -> right == NULL) return (1+h1);
         else { h2 = height (n -> right);

                return [B2] ;           // Box 2
              }
       }
}
The appropriate expressions for the two boxes B1 and B2 are
Show answer without attempting

Answer: A

0/120 correct0 marks

Related topics in Programming and Data Structures