本次CS代写的主要涉及如下领域: C++代写,北美程序代写,美国程序代写,Miami University代写,CSC419代写
Spring 2020 CSC 419 - Programming Languages - Assignment 3
Due date: Thursday, Feb 27, 2020, by midnight, upload in home folder of class
Please put your full name on the assignments and all other papers you submit! Notes for
programming assignment submissions:
All your files for an assignment should be in a subdirectory in your home directory. The subdi-
rectory will be named "assignmentX' where X is the assignment number. Examples - assignmen-
t1, assignment2, assignment3, etc. Xu will pick up files from this subdirectory after the dead-
line for the assignment.
Put a README file in the assignment directory with instructions for compiling and running the
program for the programming exercises. You may also include some test input data for which
your program works. Your program should compile in the computers in the CSC lab (Ungar
Room 426). You are required to submit source code and data files. Executable files or any oth-
er binary files will not be accepted.
Exercise 3.
Write three functions in C or C++: one that declares a large array statically, one that declares
the same large array on the stack, and one that creates the same large array on the heap. Call
each of the subprograms a large number of times (at least 100,000) and output the time re-
quired by each. Explain the results.
[9 points]
Exercise 3.
Consider the following skeletal Ada program:
procedure Main is
X : Integer;
procedure Sub3; -- This is a declaration of Sub
-- It allows Sub1 to call it
procedure Sub1 is
X : Integer;
procedure Sub2 is
begin -- of Sub
...
end; -- of Sub
begin -- of Sub
...
end; -- of Sub
procedure Sub3 is
begin -- of Sub
...
end; -- of Sub
begin -- of main
...
end; -- of main
Programming Languages - Assignment 3 1
Spring 2020 Programming Languages
Assume that the execution of this program is in the following unit order:
Main calls Sub
Sub1 calls Sub
Sub2 calls Sub
Assuming static scoping in the following, which declaration of X is the correct one for a refer-
ence to X in each of the following subprograms?
[3 points]
a. Sub1 (which declaration of X does Sub1 refer to?)
b. Sub2 (which declaration of X does Sub2 refer to?)
c. Sub3 (which declaration of X does Sub3 refer to?)
Explain your answers.
Repeat the above (a, b, c), but assume dynamic scoping.
[3 points]
Exercise 3.
a. Regarding string mutability: what happens in Python and in Ruby when defining a string and
changing one of its values? Try running this in Python and Ruby, and write down the code and
the result. Also, does this have implications in terms of reliability?
Python should be available on the lab accounts (type python from the terminal). Ruby should
also be available from your lab accounts (type irb from the terminal). For Python and Ruby, if
you don’t have it installed on your computer, you can also run it in your browser via: http://
jupyter.org or https://colab.research.google.com
[2 points]
b. Compare C++, Ruby and Python in terms of what happens when attempting to access an ar-
ray element out of range. Try running these and report the code and result.
[3 points]
Programming Languages - Assignment 3 2