View Assessment Result


Family Name: LAM
Given Name: Ka Lee
Login: 50336714
E-mail: 50336714@cityu.edu.hk
Status: Enrolled

Assessment Name: Multiple Choice Quiz 6
Instance: 3

Section: CITYU-L09
During: Fall 2002

For course: Data Structures and Algorithms
(DCO20105)

Corresponding to: SSD5
At: City University of Hong Kong



Your performance was as follows:


Total score: 80.00


1.
What would be the consequences for algorithms if recursion were removed from C++?

(a) All algorithms could still be implemented, but often less elegantly.
(b) None
(c) All algorithms could still be implemented, but the efficiency would often be catastrophically worse.
(d) Some algorithms could no longer be implemented.

Correct answer is (a)

Your score on this question is: 10.00

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



2.
Which of the following is the main reason for using recursion?

(a) To avoid templates and inheritance
(b) To use less memory
(c) To improve efficiency
(d) To obtain short, elegant solutions

Correct answer is (d)

Your score on this question is: 10.00

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



3.
A recursive function is one that

(a) calls itself
(b) uses no loops of any kind
(c) is called from main()
(d) calls other functions

Correct answer is (a)

Your score on this question is: 10.00

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



4.
The specification for an algorithm must include all of the following EXCEPT:

(a) A precise description of all the data structures used
(b) A precise description of how the output is computed from the input
(c) A precise description of the output
(d) A precise description of the input

Correct answer is (a)

Your score on this question is: 10.00

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



5.

Consider the function defined as follows.

      int  f( int n )
      {
          if( n == 0 ) return 0;
          if( (n & 1) == 0 ) return f(n/2);
          return f(n/2) + 1;
      }

The value returned by the call f( 10 ); is



(a) 2
(b) 5
(c) 1
(d) 3

Correct answer is (a)

Your score on this question is: 10.00

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



6.

Consider the following definition of a recursive function f.

      int  f( int n )
      {
          if( n == 0 ) return 0;
          if( (n & 1) == 0 ) return f(n/2);
          return f(n/2) + 1;
      }

What does f compute?



(a) A pseudo-random number between 1 and n
(b) The number of 1's in the binary expansion of the input
(c) The number of digits in the binary expansion of the input
(d) The logarithm of the input

Correct answer is (b)

Your score on this question is: 10.00

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



7.

Consider the following definition of a recursive function ff.

      int  ff( int n, int m )
      {
          if( n == 0 ) return 0;
          return  ff( n - 1, m ) + m;
      }

If the values of n and m are nonnegative, what is returned by ff( n , m )?



(a) The least common multiple of n and m
(b) The greatest common divisor of n and m
(c) The product of n and m
(d) The sum of n and m

Correct answer is (c)

Your score on this question is: 10.00

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



8.

Consider the following definition of a recursive function what?

      int  what( int (*f)(int), int x, int n )
      {
            if( n == 0 )  return x;
            return  f( what( f, x, n - 1 ) );
      }

If n is a non-negative integer, then the call what( f, x, n )returns



(a) f(x) unless f is recursive, in which case it returns fn-1(x)
(b) f(x)regardless of the value of n
(c) fn(x)
(d) f(x + n)

Correct answer is (c)

Your score on this question is: 0.00

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



9.

Consider the following recursive definition of a function to compute Fibonacci numbers.

      int  Fibonacci( int n )
      {
      if( n == 0 ) return 0;
      if( n == 1 ) return 1;
      return  F(n-1) + F(n-2);
      }

Why is the function Fibonacci problematic to use?



(a) The total number of recursive calls is prohibitively large for large n.
(b) The double recursion is difficult to implement.
(c) The depth of the recursion is prohibitively large for large n.
(d) The memory requirement is prohibitively large for large n.

Correct answer is (a)

Your score on this question is: 0.00

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



10.
Given an array of length n, the extra space requirement in merge sort due the call stack is about

(a) n
(b) log n
(c) n2
(d) some small constant

Correct answer is (a)

Your score on this question is: 10.00

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



Go to top of assessment.

Total score: 80.00