Docsity

CS1371 - Computing for Engineers Test 1 Version D - Fall Semester 2006, Exams of Computer Science

Toggle sidebar
bg1
CS1371 - Computing for Engineers Test 1 Version D September 20th, 2006
1Georgia Institute of Technology
College of Computing
CS 1371 Computing for Engineers
Test 1 Version D - Fall Semester 2006
Page 1 of 9
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 Prism ID (WebCT username) in the
spaces provided, and shade the boxes of the
corresponding numbers and/or letters.
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
pf9

Partial preview of the text

Download CS1371 - Computing for Engineers Test 1 Version D - 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 1 Version D - 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 Prism ID (WebCT username) in the

spaces provided, and shade the boxes of the

corresponding numbers and/or letters.

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: 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) isempty(here) – checks if here is null (usually represented by [], the empty vector iscell(a) – checks if a is of class cell (a cell array) ischar(a) – checks if a is of class char (a string) 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 max(a) – value and index of the max value in a min(a) – value and index of the min value in a mod(a, b) – the remainder when a is divided by b 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 struct(att,val, … ,att,val) – builds a structure with the given attribute/value pairs sum(v) – total all the elements in the vector v diag(m) – returns the diagonal elements of the matrix m image(x) - display the image from the matrix x. imread(filename) - returns a matrix representation of an image 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 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 mod(a, b) – the remainder when a is divided by b ones(rows, cols) – generate a matrix filled with 1 sort(v) – arranges the vector v in ascending numerical order 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. Consider this function: function ret = myFactorial(num) ret = 0; for I = 1:num ret = ret*I; end What is the output of myFactorial(4): A. 0 B. 4 C. [0 1 2 3 4] D. 24 E. None of the above

  2. Given the following code: a{1} = 'Yes, You will make it through'; a{2} = 'Tech by'; a{3} = 2020; x = a{1}; y = [a{2} ['You Wish!']]; z = [a(3) a(2:3)]; What are the data types of x, y and z respectively? A. char array, char array , cell B. char array, char array, double C. cell, char array, double D. cell, char array, cell E. cell, char, char array

Problem 2 – Vector Manipulations [20 Points]

Create a vector called vec that has all the even values between 10 and 46 (endpoints

included) and then do the following

- Remove all the values that are multiples of 10

- Insert 15 at the beginning of vec.

- Create a vector rvec that is the same as vec , but in reverse order

- Find the average of the values at odd indices in vec and store as oddavg

Problem 4 – Conditionals [20 Points]

You are given a vector containing the total amount of rainfall (in cm) reported to have

fallen in Atlanta on certain days. There is obviously a problem with the rainfall reporting

system because some of the values are negative, and it must be an error to report a

negative rainfall total.

You are asked to write a MATLAB function called avgRain that will take in an array of

reported daily rainfall totals (the array you are given is one example) and return the

average of ONLY the non-negative numbers (either positive or zero) in the list. You may

assume that every array of reported daily rainfall totals contains at least one element.

Example: x = avgRain([3 2 -1 -3 0 3 2])

Return: x = 2

Problem 5 – Cell Arrays [20 Points]

Write a function findLong which takes in a cell array of vectors (of data type double) and

decides which vector is the longest using a for loop. The function then returns the vector.

You can use any other necessary MATLAB function as needed.

Note: You must use a for loop to obtain credit for this question

Example: x = findLong({[1 2 3], [8 9], [4 3 8 1]})

Returns: x = [4 3 8 1]