sp07cs1371-PT2

# sp07cs1371-PT2 - CS 1371 Test Team Presents Practice Test 2...

This preview shows pages 1–3. Sign up to view the full content.

CS 1371 Test Team Presents: Practice Test 2 – Spring 2007 Recursion & Character Strings Part I: Concepts 1) Given the following recursive function, function ans = myrecur(x) if x > 10 ans = []; else ans = [(x-1) myrecur(x-2)]; end Which of the three fundamentals of recursion does this function not follow correctly? 2) Given a string variable called str , name the data type of the result of the following operations: A: double(str) B: str + 0 C: [str ‘b’] D: num2str(str) E: str + ‘b’

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

View Full Document
Part II: Coding 1) Write a MATLAB function called recursiveDecoder() which takes in an encoded string and returns an decoded one. The first character of the encoded message is the first character of the decoded message, The second character of the encoded message is the last character of the decoded message The third character of the encoded message is the second character of the decoded message The fourth character of the encoded message is the second to last character of the decoded message And so on until the entire message has been encoded Note: You must use recursion in solving this problem. The encoding algorithm is as follows: Example: recursiveDecoder(‘hoell’) should return ‘hello’ 2) Hungarian notation is a naming convention in computer programming, in which the name of an object indicates its type or intended use. In Hungarian notation, a function or variable name is denoted with the connection of lowercase “words” describing the variable, with each additional word beginning with a capital letter: i.e. “this notation is cool” would become “thisNotationIsCool” Write a function, hungarian(str)
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern