CS 333: Homework

Homeworks

Current HW

HW 1: What languages do you know?

Due Friday, Sep 10

Write down all of the programming languages you recall using. Use a broad definition of a programming languages as something that enables you to instruct a computer to complete a task automatically. For each language you recall, give a brief answer to each of the following questions.


HW 2: What languages do you want to know?

Due Monday, Sep 20

Pick three languages you do not yet know and write the equivalent of a Hello World program in each of them. Have it do something simple like print out the first ten terms of a Fibonacci series.

Do not just copy and paste an example from somewhere else. You won't learn anything. You are free to look at example programs in the language, but make sure you type up your own program from scratch. Try to give it a unique twist.

Make a small wiki page for each language that includes your program and a description of its key components. Note especially the differences in syntax between the languages. Are there any differences in naming, variable scope, or data types?

Make a separate wiki page that links to each of your language pages. Please put the label cs333F10hw02 on the central page with the links to the three other languages.

You will likely choose your two focus languages from these three, so be sure to include languages of interest to you.


HW 3: Parse trees

Due Monday, Oct 4

solution

Demonstrate that addition in C is not associative. The following two statements should print significantly different results. You need to figure out appropriate types and values for a, b, and c. Can you do the same with multiplication?

printf( "%f\n", (a + b) + c );
printf( "%f\n", a + (b + c) );

Using the Clite syntax, generate both the concrete parse trees and abstract parse trees for the following statements. Feel free to do the concrete tree automatically using flex.


Exam 1 Prep

The following are some suggested exercises for exam 1 preparation. Email the instructor with any questions you have.


HW 4: Exception handling

Due Monday, November 1

  1. Aliasing occurs when you can use one variable to change a value in memory and have that change reflected when using a different variable. For example, two pointers to the same memory location in C enable aliasing. Pick one of your selected languages for the semester and see if you can demonstrate aliasing in that language. If you can't, discuss the language features that prohibit it. Put the example or discussion up as wiki page linked to your language's main page.
  2. Write a simple example of exception handling in two of the three languages (Python, Java, C++) and in one of your selected languages. Demonstrate handling a built-in exception and a user defined exception. In Python or Java, demonstrate how the finally block works. Put your code, with comments describing how it works, on the Academics server.

HW 5: Timing

Due Monday, 6 November

Figure out how to time a function in one of your languages. Test the relative timing for the following operations. [Hint: you probably want to execute a few hundred thousand of these operations and then calculate an average.]

  1. addition
  2. multiplication
  3. division
  4. square root
  5. exponentiation