sp07cs1371-PT2

sp07cs1371-PT2 - CS 1371 Test Team Presents: Practice Test...

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

View Full Document Right Arrow Icon
CS 1371 Test Team Presents: Practice Test 2 – Spring 2007 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’
Background image of page 1

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

View Full DocumentRight Arrow Icon
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) , which takes in a character string of all lowercase
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 7

sp07cs1371-PT2 - CS 1371 Test Team Presents: Practice Test...

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

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