ABCstest3 - CS REVIEW SESSION THREE HW9_ABCs of Recursion

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
CS REVIEW SESSION THREE HW9_ABCs of Recursion Return to Assessment List Part 1 of 1 - Recursion 100.0 Points Question 1 of 8 12.5 Points A wrapper function is used to perform any tests or setup that the recursion requires. A. True B. False Question 2 of 8 12.5 Points Given the following function that computes a^b, as long as a and b are non- negative integers, choose the appropriate terminating condition: %%%%%% Separate M-File %%%%%%% <o:p></o:p> function out=myPow(a,b) if <PICK APPROPRIATE TERMINATING> out= 1; else out= a*myPow(a, b-1); end <plug in="" the="" statement="" here=""></plug> A. a == 0 B. a == 1 C. b == 0 D. b == 1 Question 3 of 8 12.5 Points A wrapper function requires the use of a helper function. A. True B. False
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Question 4 of 8 12.5 Points It is possible to make more than one recursive call to the function. A. True B. False Question 5 of 8 12.5 Points Assume you run the following piece of code: >>result=myProd([2 1 5 4 7 8]) %%%%%% Separate M-file%%%%%% function out =myFunc(vec) if length(vec)<=1 out=vec; else out=vec(end)+ myFunc(vec(1:length(vec)-1)); end %%%%%%%%%%%%%%%%%%%%%%%%%%%% What is the final value of the variable "result"? A. 27 B. [8 56 224 1120 1120 2240] C. 2240 D. [8 15 19 24 25 27] Question 6 of 8 12.5 Points Given the code below: function ret = myFact(N) ret = local_fact(N,1) function ret = local_fact(N,res) if N == 0
Background image of page 2
    ret = res; else     ret = local_fact(N-1,N*res); end Which is the helper function: A. local_fact() B. No Clue C. None. This function does not use a wrapper function. D. myFact() Question 7 of 8 12.5 Points Which are the three necessary characteristics of recursion? A. There must be a terminating condition to stop the process. B. The function must call a clone of itself. C. The parameters to that call must move the function toward the terminating condition. D. There must be an if statement. E. There must be a switch statement. F. A stack needs to be defined. Question 8 of 8 12.5 Points <!--[if !supportLists]--> 1. <!--[endif]--> Given the following function:<o:p></o:p> function ret = strFix(in) if length(in) == 0     ret = []; elseif strcmp(in{1}(1),'h')     ret = ['*', in{1}(2:end), '* ', strFix(in(2:end))]; elseif strcmp(in{1}(1), 'j')     ret = [ in{1}(2:end), '-', strFix(in(2:end))]; else     ret = [ in{1}, ' ', strFix(in(2:end))]; end <o:p></o:p> <o:p>What will be the value of B after the following code is executed:</o:p> A =  {'I'    'hlove'    'jcomputer'    'science.'}; B = strFix(A)
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
B. I*love* computer-science. C. I *love* computer-science. D. science. computer- I *love*
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/21/2011 for the course CS 1371 taught by Professor Stallworth during the Fall '08 term at Georgia Institute of Technology.

Page1 / 25

ABCstest3 - CS REVIEW SESSION THREE HW9_ABCs of Recursion

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online