Docsity

Computing for Engineers Test 2 Version B - Fall Semester 2006, Exams of Computer Science

Toggle sidebar
bg1
CS1371 - Computing for Engineers Test 2 Version B October 25th, 2006
1Georgia Institute of Technology
College of Computing
CS 1371 Computing for Engineers
Test 2 Version B - Fall Semester 2006
Page 1 of 8
0 0 0 0 0 0 0 0 0
1 1 1 1 1 1 1 1 1
2 2 2 2 2 2 2 2 2
3 3 3 3 3 3 3 3 3
4 4 4 4 4 4 4 4 4
5 5 5 5 5 5 5 5 5
6 6 6 6 6 6 6 6 6
7 7 7 7 7 7 7 7 7
8 8 8 8 8 8 8 8 8
9 9 9 9 9 9 9 9 9
A A A A A A A A A
B B B B B B B B B
C C C C C C C C C
D D D D D D D D D
E E E E E E E E E
F FFFFFFFF
G G G G G G G G G
H H H H H H H H H
I I I I I I I I I
J J J J J J J J J
K K K K K K K K K
L L L L L L L L L
M M M M M M M M M
N N N N N N N N N
O O O O O O O O O
P P P P P P P P P
Q Q Q Q Q Q Q Q Q
R R R R R R R R R
S S S S S S S S S
T TTTTTTTT
U U U U U U U U U
V V V V V V V V V
W W W W W W W W W
X X X X X X X X X
Y Y Y Y Y Y Y Y Y
Z ZZZZZZZZ
↑ Print your WebCT username in the spaces
provided, and shade the boxes of the
corresponding numbers and/or letters. If your
username is longer than 9 characters, shade in
the boxes corresponding to the first 9.
I hereby signify that this examination paper
contains my own work exclusively, and I have
neither given nor received inappropriate help
during the taking of this examination, in
compliance with the letter and spirit of the
Academic Honor Code of Georgia Tech.
Name (print):
Signature:
TA / Section: ____________________________
Prob. Poss.
Pts
Earned
Pts
Lost
Pts by
(cover) - -
1 20
2 20
3 20
4 20
5 20
TOTAL 100
Please Note: Failure to complete this front sheet correctly
will cost you 5% of your grade.
Please turn off (or silence) and put away any cell
phones, beepers/pagers, personal radios or music
players that you have in your possession
Good Luck!
pf3
pf4
pf5
pf8

Partial preview of the text

Download Computing for Engineers Test 2 Version B - Fall Semester 2006 and more Exams Computer Science in PDF only on Docsity!

1 Georgia Institute of Technology

College of Computing

CS 1371 Computing for Engineers

Test 2 Version B - Fall Semester 2006

A A A A A A A A A

B B B B B B B B B

C C C C C C C C C

D D D D D D D D D

E E E E E E E E E

F F F F F F F F F

G G G G G G G G G

H H H H H H H H H

I I I I I I I I I

J J J J J J J J J

K K K K K K K K K

L L L L L L L L L

M M M M M M M M M

N N N N N N N N N

O O O O O O O O O

P P P P P P P P P

Q Q Q Q Q Q Q Q Q

R R R R R R R R R

S S S S S S S S S

T T T T T T T T T

U U U U U U U U U

V V V V V V V V V

W W W W W W W W W

X X X X X X X X X

Y Y Y Y Y Y Y Y Y

Z Z Z Z Z Z Z Z Z

↑ Print your WebCT username in the spaces

provided, and shade the boxes of the

corresponding numbers and/or letters. If your

username is longer than 9 characters, shade in

the boxes corresponding to the first 9.

I hereby signify that this examination paper

contains my own work exclusively, and I have

neither given nor received inappropriate help

during the taking of this examination, in

compliance with the letter and spirit of the

Academic Honor Code of Georgia Tech.

Name (print):

Signature:

TA / Section: ____________________________

Prob.

Poss.

Pts

Earned

Pts

Lost

Pts

by

(cover) - -

TOTAL 100

Please Note: Failure to complete this front sheet correctly

will cost you 5% of your grade.

Please turn off (or silence) and put away any cell

phones, beepers/pagers, personal radios or music

players that you have in your possession

Good Luck!

Academic misconduct (including - but not limited to - examples on the list below) could result in a zero score

on this examination, an “F” final grade in the course, and/or other disciplinary action:

  • Failure to cooperate with or follow directions given by a proctor.
  • Failure to stop writing when the allotted time is up (as reported by a proctor).
  • Communication with anyone other than a proctor for ANY reason in ANY language in ANY manner.
  • Sharing of ANYTHING (e.g. pencils, erasers, paper).
  • Writing on paper that is not given to you by a proctor.
  • Using cell phones, beepers, personal radios or music players, etc. during the exam.
  • Using calculators (unless explicitly permitted) or hand-held computers during the exam.
  • Using books or other reference material during the exam.
  • Disruption of the exam setting. Reference Section: diag(m) – returns the diagonal elements of the matrix m factorial(n) – returns n! find(m) – returns the indices of the true elements of m getfield(a,att) – returns the value of field att in the structure a – equivalent to a.(att) image(x) - display the image from the matrix x. imread(filename) - returns a matrix representation of an image iscell(a) – checks if a is of class cell (a cell array) ischar(a) – checks if a is of class char (a string) isempty(here) – checks if here is null (usually represented by [], the empty vector isfield(a,att) – checks if att is a field in the structure a isstruct(a) – checks if a is a structure length(a) – largest dimension of a magic(n) – builds a n * n magic square max(a) – value and index of the max value in a mesh(x, y, z) – plot the surface defined by the x, y and z arrays with colored lines and white faces [xx, yy] = meshgrid(x, y) – compute the plaid from the x and y vectors min(a) – value and index of the min value in a mod(a, b) – the remainder when a is divided by b ones(rows, cols) – generate a matrix filled with 1 prod(v) – compute the product of all the elements in a vector v rmfield(str, att) – removes a structure field setfield(str, att, value) – set a structure field – equivalent to str.(att) = value sin(th) – sin of the angle in radians size(a) – all the dimensions of a sort(v) – arranges the vector v in ascending numerical order struct(att,val, … ,att,val) – builds a structure with the given attribute/value pairs sum(v) – total all the elements in the vector v surf(x, y, z) – plot the surface defined by the x, y and z arrays with colored faces and black lines title(str) – titles the plot with the given string [x, fs] = wavread(filename) – gives the waveform and sampling frequency for a .wav file (x/y/z)label(str) – labels the plot axes with the given string zeros(rows, cols) – generate a matrix filled with 0
  1. A recursive function always has the following (Circle all that apply): A. A call to a clone of the function itself B. A vector C. A move towards termination D. A terminating condition E. A return value
  2. If the function z = x^2 is rotated about the z-axis where x has a range of x = 0 to x = 3 and theta has a range of theta = –pi to theta = 0, how far would the surface created go about the z-axis? A. The surface would rotate all the way about the z-axis. B. The surface would only rotate halfway about the z-axis. C. The surface would only rotate a fourth of the way about the z-axis. D. The surface would not be plotted because theta has negative values. .

Problem 2 – Structures [20 Points]

Read the following piece of code and then answer the questions that follow.

carA = struct('Make', 'Chevrolet', 'Model', 'Impala', 'Year',

carB = struct('Make', 'Ford', 'Model', 'Taurus', 'Year', 2000)

carC = setfield(carA, 'Year', 1991)

cars = [carA carB carC]

cars(2).Color = 'red'

carA = rmfield(carA, 'Model')

W = cars(2).Year

X = getfield(cars(3), 'Make')

Y = isfield(carA, 'Model')

Z = cars(1).Color

A. What is the output of the following variables when the script above is executed:

Denote a structre in the following manner:

:

:

W = _____________________________________________________

X = _____________________________________________________

Y = _____________________________________________________

Z = _____________________________________________________

5 pt EXTRA CREDIT: Create a new structure array cars2 which will be the same as

cars except without the ‘Year’ field.

Problem 4 – Recursion [20 Points]

Write a function mylower that takes in a string and returns all the lowercase letters in

the given string.

Note: You must use recursion to receive any credit.

Example: x = mylower(‘HmathTisSReasyFHD’])

Returns: x = ‘mathiseasy’

Problem 5 – Plotting [20 Points]

A mathematician is interested in finding out what a body of rotation would look like for

different ranges of x-values. Write a function called rotatefun that takes in a vector

(of length 2) that contains the first and last x-values in the x range and returns nothing.

The function should rotate the function z = 10*x^2 - x^3 about the z-axis using

an x-value range with an appropriate number of points specified by the vector provided

to the function. The function generates a plot of the rotated surface. The plot should have

the following characteristics:

• The plot should produce a smoothed, shaded surface

• The plot should use the cool color map

• Put an appropriate title and label all the axes

Example: rotatefun([4 8]) would rotate the above f(x) function about the z-axis

from x = 4 to x = 8