View Assessment Result: Multiple Choice Quiz 10



Your performance was as follows:

1.

Consider the following recursive definition of a function search that performs search in a binary tree.

bool search(Type  a, Tree  T)  {
  if (empty(T))  {
    return false;
  }
  else
  if(a == data(T))  {
    return true;
  }
  else  {
    bool  bl = search(a, left(L));
    bool  br = search(a, right(L));
    return  bl || br;
  }
}

Which of the following describes a problem with the function when executed?



(a) It might take linear time unnecessarily.
(b) It might fail to terminate.
(c) It might take quadratic time unnecessarily.
(d) It might terminate prematurely.

Correct answer is (a)

Your score on this question is: 10.00

Feedback:
   See section 2.3.1 of the course notes.
   (a) No Feedback



2.
A node in a tree that does not have a predecessor is called

(a) an internal node
(b) a leaf
(c) a root
(d) a parent node

Correct answer is (c)

Your score on this question is: 10.00

Feedback:
   See section 2.3.1 of the course notes.
   (c) No Feedback



3.
Which of the following is true about the depth of a tree with exactly 3 nodes?

(a) There is no bound on the depth.
(b) It is at most 1.
(c) It is at most 2.
(d) It is at most 3.

Correct answer is (c)

Your score on this question is: 10.00

Feedback:
   See section 2.3.1 of the course notes.
   (c) No Feedback



4.
Which of the following is true about the total number of nodes in a binary tree with depth 2?

(a) It is at most 2.
(b) There is no bound on the number of nodes.
(c) It is at most 4.
(d) It is at most 7.

Correct answer is (d)

Your score on this question is: 10.00

Feedback:
   See section 2.3.1 of the course notes.
   (d) No Feedback



5.
A full node in a binary tree has how many children?

(a) 1
(b) 2
(c) 0
(d) 1 or 2

Correct answer is (b)

Your score on this question is: 10.00

Feedback:
   See section 2.3.1 of the course notes.
   (b) No Feedback



6.

Consider the following pseudo-code, which indicates part of a standard binary tree algorithm.

      print( node )
      {
      print  data;
      if( there is a left child )  print( left child );
      if( there is a right child )  print( right child );
      }

Which of the following is the standard name for this algorithm?



(a) Inorder traversal
(b) Binary search
(c) Postorder traversal
(d) Preorder traversal

Correct answer is (d)

Your score on this question is: 10.00

Feedback:
   See section 2.3.1 of the course notes.
   (d) No Feedback



7.
Which of the following traversals of a binary search tree will produce a sorted list if a visit to a node prints what is stored there?

(a) Level-by-level
(b) Postorder
(c) Inorder
(d) Preorder

Correct answer is (c)

Your score on this question is: 10.00

Feedback:
   See section 2.3.1 of the course notes.
   (c) No Feedback



8.

Suppose S is a binary search tree and x is not an element of S. Consider the following code fragment.

      S.remove( x );
      S.insert( x );

If T is the tree that results from executing the fragment, what is the relationship between S and T?



(a) S and T differ but how depends on S.
(b) S is a proper subtree of T.
(c) S and T differ in exactly the root.
(d) S and T are the same.

Correct answer is (a)

Your score on this question is: 10.00

Feedback:
   See section 2.3.1 of the course notes.
   (a) No Feedback



9.
If numbers 1,2,...,n are inserted into a binary search tree, in order, then the result for large n is a

(a) totally unbalanced tree
(b) tree where all nodes are full
(c) completely balanced tree
(d) mildly unbalanced tree

Correct answer is (a)

Your score on this question is: 10.00

Feedback:
   See section 2.3.1 of the course notes.
   (a) No Feedback



10.
Which of the following sequences cannot represent values visited during a binary search?

(a) 50, 40, 30, 20, 10
(b) 30, 50, 40, 45, 42
(c) 10, 20, 30, 40, 50
(d) 10, 20, 30, 15, 18

Correct answer is (d)

Your score on this question is: 10.00

Feedback:
   See section 2.3.1 of the course notes.
   (d) No Feedback



Go to top of assessment.

Total score: 100.00