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 terminate prematurely.
(c) It might fail to terminate.
(d) It might take quadratic time unnecessarily.

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 root
(c) a parent node
(d) a leaf

Correct answer is (b)

Your score on this question is: 0.00

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



3.
A node in a tree that does not have any children is called

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

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



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

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

Correct answer is (c)

Your score on this question is: 0.00

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



5.

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) Postorder traversal
(c) Preorder traversal
(d) Binary search

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



6.

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

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

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



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

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



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) Inorder
(b) Preorder
(c) Postorder
(d) Level-by-level

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



8.
During a failed search for an element in a completely balanced binary search tree of size 1,000,000, approximately how many nodes of the tree is visited?

(a) 1000
(b) 10,000
(c) 200
(d) 20

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



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

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

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



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

(a) reasonably balanced tree
(b) tree where all nodes are full
(c) totally unbalanced tree
(d) completely balanced 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



Go to top of assessment.

Total score: 80.00