
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

ITK 179, Fall 2008 Programming Assignment 3, 30 points
In this assignment we will practice how to measure the efficiency of your programs and do your best to improve your programs.
(a) i. Put n random values into A so that A[0], A[1],... A[n − 1] are n distinct random integers between 0 and n − 1. (Note that all number in A must be distinct.) ii. Then, calculate B such that for 0 ≤ i < n, B[i] = A[0] + A[1] + · · · + A[i].
(b) i. Put n random values into A so that A[0], A[1],... A[n − 1] are n random integers between 0 and n − 1 (Note that the numbers need not to be distinct.) ii. Then, calculate B such that for 0 ≤ i < n, B[i] = A[0] + A[1] + · · · + A[A[i]].
Hint: Use Math.rondom() to get a random double between 0 and 1 (not including 1).
As previous assignments, you are encouraged to implement this assignment on your Unix account. Put all your works in the directory /ITK179/Asg3 under your home directory. (Note: Unix is case sensitive.) If you decide to do so, you have to change the mode of the directory to readable for every one after the due date, so I can grade your work. You still have to write up a report and submit a hard copy. However, you don’t have to websubmit your programs. You have to keep your work in your account to the end of the semester.
Note: Follow the instructions for submission. (No late work will be accepted)
Due: Oct. 6, Monday ©c Chung-Chih Li P-1/