CS1371_PracticeTest1_Fall_2007

CS1371_PracticeTest1_Fall_2007 - CS 1371 Practice Test Fall...

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

View Full Document Right Arrow Icon
CS 1371 Practice Test – Fall 2007 Problem 1 – Vector Manipulation A. Consider the following code : A = 1:2:20; B = linspace(1,10,10); B((mod(B, 3) == 0)||((mod(B,5)==0)) = []; C = [A(5:end) A(1:5)]; [M in] = max(C); A(in) = -1; D = B([3 2 6]).*2; A(2:6) What are the values of the variables after the code is run? A : ___________________________________________________________________________ B : ___________________________________________________________________________ C : ___________________________________________________________________________ D : ___________________________________________________________________________ B. For each of the following, only a line or two of code is required. 1. Create a vector, vec1 , that has 20 values between 89 and 101. 2. Swap the first and second halves of vec1 and store in vec2 . 3. Find the smallest value in vec2 and its location. Store the value as M and the location as L . C. Evaluate the following logical expressions as true or false: A = true B = false 1. any([A B]) : _____________________________________________________________ 2. ( : __________________________________________________________ 3. : __________________________________________________________
Background image of page 1

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

View Full DocumentRight Arrow Icon
Problem 2 – String Manipulation A. Anagrams are words which contain the same letters, except in a different order. For example, “egret” and “greet” are anagrams. 1.) Write a function called isAnagram that consumes two strings and returns a Boolean: true if the strings are anagrams or false if they are not. Note:
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

CS1371_PracticeTest1_Fall_2007 - CS 1371 Practice Test Fall...

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