CS 315
Homework Assignment 1


Assigned:  November 21, 2018
Due:  November 28, 2018, 23:59

Arrays in C, Javascript, Python, Perl and PHP

An array is an aggregate data structure that is designed to store a group of objects. Most programming langauges provide built-in support for arrays.

In this homework assignment, you will compare the array data structure provided in five different programming languages: C, Javascript, Python, Perl and PHP. You will investigate how the following design issues are addressed in these programming languages:

  1. What types are legal for subscripts?
  2. Are subscripting expressions in element references range checked?
  3. When are subscript ranges bound?
  4. When does allocation take place?
  5. Are ragged or rectangular multidimensional arrays allowed, or both?
  6. What is the maximum number of subscripts?
  7. Can array objects be initialized?
  8. Are any kind of slices supported?

For each design issue and for each language, explain the answer by giving examples using code segments in these languages. You can illustrate the answers to these questions, in different parts of a single program. The example program must be complete. It should compile and execute on the dijkstra.cs.bilkent.edu.tr machine. Also discuss, in your opinion which language is the best for array operations. Explain why.

Note that Python does not have built-in support for Arrays, but Python lists can be used instead. On the other hand array module in Python defines an object type which can compactly represent an array of basic values: characters, integers, floating point numbers. Arrays are sequence types and behave very much like lists, except that the type of objects stored in them is constrained. The type is specified at object creation time by using a type code, which is a single character.

You should prepare HTML files for Javascript and PHP programs.

Put your example programs in different files, each having your last name and name, and a description for the language  and scoping used. For example, lastname_name_C.c, lastname_name_python.py, lastname_name_perl.pl, lastname_name_javascript.html and lastname_name_php.php (or lastname_name_php.html). Put all of these files into a single zip or rar file.

You may use the tutorials available in the Internet as a reference, but do not derive your example from the contents of the tutorials. If you do so, your programs may be similar to others in the class, that causes a disciplinary investigation.

Then, e-mail your report, along with the compressed file containing the example programs, to the TA, Gizem Çaylak <gizem.caylak@bilkent.edu.tr>.

Collaboration on the homework is not allowed.

Suggestion: Do not postpone the execution of your programs to the last minute! The dijkstra machine might be overloaded, then.