Computer Science 433
Programming Languages

Fall 2014, The College of Saint Rose

Program/Problem Set 8: Datatypes, Expressions and Assignments
Due: 11:59 PM, Wednesday, November 12, 2014

This problem set consists of several questions, some of which require you to complete relatively short programming tasks. You may work alone or with a partner on this assignment.

Questions and Programs

Question 1: Sebesta Problem Set Exercise 15, p. 314. (3 points)

Question 2: Sebesta Problem Set Exercise 21, p. 315. (3 points)

Question 3: Sebesta Programming Exercise 7, p. 316. Include your C program in your submission. Include your actual timing results as well as a brief analysis in your response. (6 points)

Question 4: Sebesta Problem Set Exercise 4, p. 343. (3 points)

Question 5: Answer Sebesta Problem Set Exercise 13, p. 344, then do Sebesta Programming Exercises 1 and 2, p. 345. (8 points)

Question 6: Sebesta Programming Exercise 9, p. 346. Include your program in your submission and the actual timing results. (6 points)

For the next two questions, consider the following memory allocation of linked lists. head and ptr are stack (local) variables that point to list nodes. List nodes were allocated in heap memory, and each list node consists of a value (an int) and a pointer to another list node. A / through a pointer field indicates a null pointer.

Question 7: If a garbage collection operation executes, what memory can be reclaimed? (3 points)

Question 8: If the head variable goes out of scope and a garbage collection operation executes, what memory can be reclaimed? (3 points)

Question 9: (10 points) Write a program in some language that supports both 32- and 64-bit floating point types (e.g., C, C++, Java) that demonstrates the importance of evaulation order. One way to do this is as follows. Add together 10 copies each of the numbers 0.1, 0.01, 0.001, ..., 0.000000001. Do this both in order from largest to smallest and from smallest to largest. Also do it with 32-bit values (floats) and 64-bit values (doubles). Print your results with 15 digits after the decimal point and thoroughly explain what you observe.

Submission

Before 11:59 PM, Wednesday, November 12, 2014, submit your work for grading. Create and submit a single archive file (a .7z or .zip file containing all required files) using Submission Box under assignment "PS8".

Grading

This assignment will be graded out of 45 points.

Feature

Value Score
Question 1: PS Exercise 15 3
Question 2: PS Exercise 21 3
Question 3: Programming Exercise 7 program 2
Question 3: Programming Exercise 7 explanation 4
Question 4: PS Exercise 4 3
Question 5: PS Exercise 13 response 3
Question 5: Programming Exercises 1, 2 programs 5
Question 6: Programming Exercise 9 program 3
Question 6: Programming Exercise 9 explanation 3
Question 7: Garbage collection part 1 3
Question 8: Garbage collection part 2 3
Question 9: Program 5
Question 9: Results and analysis 5
Total 45