



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!




Title: “Program Assignment 1: Analyzing Program Performance” Points: 100 points – 60pts for coded portion, 40 points for written analysis Due Date: Wednesday September 25, 2002 Objectives: (1) To reinforce the concepts underlying the asymptotic analysis of a program’s performance behavior. (2) Begin to program in Java. Description: Create a Java program that produces the necessary data to determine the asymptotic behavior of three different algorithms that perform operations on matrices. Do this according to the steps shown below.
portion of your assignment. How accurate are your numbers? Did you get what you expected? References: Notes: Lecture Notes for Days 2, 3 & 4 Restrictions: Your source file shall begin with comments containing the following information: / Name: Course: Assignment title: Date: / Input Specification: Internal to the source code. Output Specification: Timing information and any other output produced by your program can be written to the screen for this program. All other information should be included in your write-up. Deliverables: (1) Source code file on a floppy disk with the following information: Your name, COP 3503H, Assignment title, and Date. (2) The write-up for this assignment described in other parts of this document. (3) Place hard copies of (1) and (2) along with your disk in a large envelope, so that you do not need to fold the printouts or your report. CLEARLY, label the envelope with the following information: your name, your id number, COP 3503H, Assignment title, and the date. Write-up: A complete write-up is one of the deliverables for this assignment. A separate document (see the course web-site) describes the make-up of this write-up. Along with the items described in that separate document you will need to include the following in your report:
Example: Martix B 2 3 2 1 4 6 3 2 2 Matrix C 4 3 2 1 3 3 2 2 4 Matrix C = A[n,m] + B[n,m] 2 + 4 = 6 3 + 3 = 6 2 + 2 = 4 1 + 1 = 2 4 + 3 = 7 6 + 3 = 9 3 + 2 = 5 2 + 2 = 4 2 + 4 = 6 Algorithm #2 – Matrix Multiplication for (i = 0; i < n; i++) for (j = 0; j < n; j++) for (k = A[i][j] = 0; k < n; k++) A[i][j] += B[i][k] * C[k][j]; In general: matrix multiplication of two matrices B[n,m] and C[m,r] is defined as: ^ ^ (b[n, 1 ] c[ 1 , 1 ] b[n, 2 ] c[ 2 , 1 ] ... b[n, m (b[ 2 , 1 ] c[ 1 , 1 ] b[ 2 , 2 ] c[ 2 , 1 ] ... b[ 2 , m (b[ 1 , 1 ] c[ 1 , 1 ] b[ 1 , 2 ] c[ 2 , 1 ] ... b[ 1 ,m ] A[ i, j ] (Note that the dimensions of A are n r, in the general case, since m = m) Since we are dealing with only square matrices n = r. Example: Matrix B 2 3 2 1 4 6
Matrix C 4 3 2 1 3 3
Matrix A = B C (24 + 31 + 22) (23 + 33 + 22) (22 + 33 + 24) (14 + 41 + 62) (13 + 43 + 62) (12 + 43 + 64) (34 + 21 + 22) (33 + 23 + 22) (32 + 23 + 2*4) Thus Matrix A is: 15 19 21 20 27 38 18 19 20 Algorithm #3 – Matrix Transposition for (i = 0; i < n-1; i++) for (j = i+1; j < n; j++){ temp = A[i][j]; A[i][j] = A[j][i]; A[j][i] = temp; } In general, the transpose of a matrix is the matrix that results from the interchanging of its rows and columns. Given a matrix B, its transpose is generally denoted as BT. Example: Matrix B 2 3 2