Assigned Th 5/22/2008, due Fr 5/30 at 4pm. 50 points.
http://www.cs.nyu.edu/courses/summer08/G22.3033-002/
Homeworks are due on Fridays at 9pm. This deadline will be strictly enforced.
Email your answers to Robert Soulé robert.soule@gmail.com. Please put your solutions to VBA programming problems in a powerpoint presentation. For all other questions (including programming problems in other languages), just send a simple text file, such as what you get when using Emacs, Vi, Notepad, or the "save as text only" feature in Word.
Please make sure that your code works with the compilers and tools installed at CIWW. Specifically, please test:
doowop1
(see http://www.cims.nyu.edu/systems/resources/computeservers/).
(5+6+6 = 17 points)
Sub PrintArray(Arr())
Debug.Print "PrintArray:"
For I = 0 To UBound(Arr)
Debug.Print " " & I & " " & Arr(I)
Next I
End Sub
Sub Main()
Dim fruits(2)
fruits(0) = "apple"
PrintArray fruits
fruits(1) = "orange"
fruits(2) = "banana"
PrintArray fruits
End Sub
(5 + 8 = 13 points)
(2 - ((2 - 2) - (2 * 2)))
And, Or, Xor, Eqv,
Imp) on the same line, but in fact, they do not all have the same
precedence. Does implication (“Imp”) have a higher precedence,
lower precedence, or the same precedence as conjunction (“And”)
in VBA? Describe experiments for answering this question.
(10 points) Write a function that computes the Euclidian distance between two arrays. The Euclidian distance between two vectors A and B is defined as
sqrt((A0-B0)^2 + ... + (An-Bn)^2)
For example, consider the following test driver:
Sub Main()
Dim x1(2) As Double, x2(2) As Double
x1(0) = 0: x1(1) = 0: x1(2) = 0
x2(0) = 0: x2(1) = 0: x2(2) = 0
Debug.Print EuclidDistance(x1, x2)
x2(0) = 1
Debug.Print EuclidDistance(x1, x2)
x1(2) = 1
Debug.Print EuclidDistance(x1, x2)
End Sub
The program should print 0, 1, and 1.41421.
(10 points)
Write a function AverageRows that computes the average of each row in a two-dimensional array, and writes the results to a one-dimensional array. For example, consider the following test driver:
Sub Main()
Dim x(1, 2) As Double
x(0, 0) = 1: x(0, 1) = 2: x(0, 2) = 0
x(1, 0) = 0: x(1, 1) = 0: x(1, 2) = 2
Dim y(1) As Double
Call AverageRows(y, x)
Debug.Print y(0) & ", " & y(1)
End Sub
The program should print 1, 0.66667.