In this project we deal with handling sparse matrices. We are interested in nxn matrices that...
Fantastic news! We've Found the answer you've been seeking!
Transcribed Image Text:
In this project we deal with handling sparse matrices. We are interested in nxn matrices that represent the 'retweets' that take place among a set of n Twitter users. In particular, the element A[i,j] of matrix A represents the number of times user i has retweeted user j in a specific period. We store these matrices in a data structure called "Compact Retweet Matrix" (CRM), which is explained in detail below. In this project you are asked to define this data structure in a class, together with a set of methods that operate on it. As an example, consider a set of 10 Twitter users and the following 10x10 matrix (consisting of 10 rows and 10 columns, each one numbered using integers from 0 to 9). The non-zero values are in red font just for the sake of clarity. 2 12 0 0 2 0 0 0 0 0 0 0 1 2 3 4 5 6 7 69 0 0 0 0 0 0 0 0 OO 0 8 0 9 37 1 0 0 7 0 0 15 0 0 0 29 values array: 0 1 2 12 5 4 M 3 0 0 0 0 0 0 0 38 0 0 4 7 6 5 4 5 0 0 0 0 0 0 0 0 OO 2 13 1 0 5 0 0 0 0 0 0 0 85 0 0 6 7 8 9 18 15 6 0 4 0 13 0 0 0 0 0 0 7 0 0 0 1 0 54 0 0 0 0 We consider the CRM as a triplet of arrays (values, rowPos, and colpos) which collectively include all the above information. In particular: • The values array has size equal to the number of non-zero values in the matrix, and contains all these values, by the order they appear in the matrix. In the above matrix, there are 18 non-zero values. (The highlighting is used for the connection with the next array, please ignore it for now.) 8 0 0 6 0 18 0 0 92 0 20 10 11 12 13 54 17 38 85 9 0 OO 0 0 0 0 17 0 0 0 0 14 15 16 17 92 37 29 20 • The rowPos array has size equal to the number of users (10 in our case), and for each user it contains the position in values array in which the first nonzero value corresponding to this user appears. The highlighting colors are used in order to help you understand the relation between arrays rowPos and values. rowPos array: 0 1 2 3 4 5 02 8 Therefore, rowPos[0] = 0 indicates that the non-zero values in row 0 of the matrix start being stored at position 0 of the values array. Indeed, it is values[0]-12 and 12 is the first non-zero element in row (user) 0 of the matrix. Similarly, rowPos[1] = 2 indicates that the non-zero values in row 1 of the matrix start at index position 2 of the values array. Indeed, at index position 2 (i.e., values[2]), the value is 4 which is the first non-zero value in row 1. Therefore, the non-zero values of user 0 start from position 0 of the values array and extend up to position 1, since in position 2 we start storing the non-zero values of user 1, and hence they are 12 and 5. In the same spirit, rowPos[7] contains the value 12. This indicates that the first non-zero value in row 7 of the matrix can be found at values[12], which is 38. The non-zero values of user 9 extend from position 15 of the values array until, obviously, the end of it. We use -1 in the rowPos array to indicate the fact that a row does not contain any non-zero values. colPos array: • The colPos array has size equal to the number of non-zero values in the matrix (18 in our case), and for each such value it contains the column of the matrix in which it appears. 0 1 2 3 6 7 8 9 9 -1 12 -1 4 5 24 6 1 8 00 6 7 7 2 6 INSTRUCTIONS AND GUIDELINES 8 9 8 1 00 10 11 12 13 14 15 16 17 7 9 3 5 8 0 1 8 сл 00 Your program should be reading a matrix and it should be storing it in a CRM data structure. Then it should be able to perform queries on this structure. Input format: For the purposes of this project, when we give a matrix as an input, we will be providing that in the sparse format, i.e., a vector (row, col, value) for each non-zero value, indicating the row and column of the matrix in which this value appears. In the first line of the input, we give the total number of rows and the total number of columns of the matrix. For example, for the matrix above the input should be the following: 10 10 18 0212 045 164 217 286 322 36 13 371 4818 5115 5754 5917 73 38 75 85 7892 9037 91 29 98 20 <- Total number of rows and columns <- Total number of non-zero values <- row number, column number and value. (We continue providing one such vector for each non-zero value.) In this project we deal with handling sparse matrices. We are interested in nxn matrices that represent the 'retweets' that take place among a set of n Twitter users. In particular, the element A[i,j] of matrix A represents the number of times user i has retweeted user j in a specific period. We store these matrices in a data structure called "Compact Retweet Matrix" (CRM), which is explained in detail below. In this project you are asked to define this data structure in a class, together with a set of methods that operate on it. As an example, consider a set of 10 Twitter users and the following 10x10 matrix (consisting of 10 rows and 10 columns, each one numbered using integers from 0 to 9). The non-zero values are in red font just for the sake of clarity. 2 12 0 0 2 0 0 0 0 0 0 0 1 2 3 4 5 6 7 69 0 0 0 0 0 0 0 0 OO 0 8 0 9 37 1 0 0 7 0 0 15 0 0 0 29 values array: 0 1 2 12 5 4 M 3 0 0 0 0 0 0 0 38 0 0 4 7 6 5 4 5 0 0 0 0 0 0 0 0 OO 2 13 1 0 5 0 0 0 0 0 0 0 85 0 0 6 7 8 9 18 15 6 0 4 0 13 0 0 0 0 0 0 7 0 0 0 1 0 54 0 0 0 0 We consider the CRM as a triplet of arrays (values, rowPos, and colpos) which collectively include all the above information. In particular: • The values array has size equal to the number of non-zero values in the matrix, and contains all these values, by the order they appear in the matrix. In the above matrix, there are 18 non-zero values. (The highlighting is used for the connection with the next array, please ignore it for now.) 8 0 0 6 0 18 0 0 92 0 20 10 11 12 13 54 17 38 85 9 0 OO 0 0 0 0 17 0 0 0 0 14 15 16 17 92 37 29 20 • The rowPos array has size equal to the number of users (10 in our case), and for each user it contains the position in values array in which the first nonzero value corresponding to this user appears. The highlighting colors are used in order to help you understand the relation between arrays rowPos and values. rowPos array: 0 1 2 3 4 5 02 8 Therefore, rowPos[0] = 0 indicates that the non-zero values in row 0 of the matrix start being stored at position 0 of the values array. Indeed, it is values[0]-12 and 12 is the first non-zero element in row (user) 0 of the matrix. Similarly, rowPos[1] = 2 indicates that the non-zero values in row 1 of the matrix start at index position 2 of the values array. Indeed, at index position 2 (i.e., values[2]), the value is 4 which is the first non-zero value in row 1. Therefore, the non-zero values of user 0 start from position 0 of the values array and extend up to position 1, since in position 2 we start storing the non-zero values of user 1, and hence they are 12 and 5. In the same spirit, rowPos[7] contains the value 12. This indicates that the first non-zero value in row 7 of the matrix can be found at values[12], which is 38. The non-zero values of user 9 extend from position 15 of the values array until, obviously, the end of it. We use -1 in the rowPos array to indicate the fact that a row does not contain any non-zero values. colPos array: • The colPos array has size equal to the number of non-zero values in the matrix (18 in our case), and for each such value it contains the column of the matrix in which it appears. 0 1 2 3 6 7 8 9 9 -1 12 -1 4 5 24 6 1 8 00 6 7 7 2 6 INSTRUCTIONS AND GUIDELINES 8 9 8 1 00 10 11 12 13 14 15 16 17 7 9 3 5 8 0 1 8 сл 00 Your program should be reading a matrix and it should be storing it in a CRM data structure. Then it should be able to perform queries on this structure. Input format: For the purposes of this project, when we give a matrix as an input, we will be providing that in the sparse format, i.e., a vector (row, col, value) for each non-zero value, indicating the row and column of the matrix in which this value appears. In the first line of the input, we give the total number of rows and the total number of columns of the matrix. For example, for the matrix above the input should be the following: 10 10 18 0212 045 164 217 286 322 36 13 371 4818 5115 5754 5917 73 38 75 85 7892 9037 91 29 98 20 <- Total number of rows and columns <- Total number of non-zero values <- row number, column number and value. (We continue providing one such vector for each non-zero value.)
Expert Answer:
Related Book For
Accounting Information Systems
ISBN: 978-0133428537
13th edition
Authors: Marshall B. Romney, Paul J. Steinbart
Posted Date:
Students also viewed these databases questions
-
How does organizational culture intersect with broader societal norms, values, and trends, and what challenges and opportunities does this present for fostering inclusivity, diversity, and ethical...
-
9.1 Exercise (JDK Source Code): Extract the source code of the class Math from the JDK source code ("$JAVA_HOME" "src.zip" "Math.java" under folder "java.lang"). Study how constants such as E and...
-
A 500 mm diameter closed-end steel pipe pile is to be driven to a depth of 17 m into the following soil profile. Depth (m) 0-2.0 2.0-6.5 6.5 16.0 16.0 17.5 Soil Classification Silty sand Fine to...
-
The following data relating to direct materials cost for August of the current year are taken from the records of Happy Tots Inc., a manufacturer of plastic toys: Quantity of direct materials used...
-
Jacaranda Builders is undertaking an analysis of supplier costs in order to evaluate the relative costs and performance of each supplier. They have isolated a range of activities that are consumed by...
-
For the isotope 202 Hg, express the percentage of the fundamental particles in the nucleus that are neutrons.
-
The \( \qquad \) theory says that covert aspects of fraud may be as important as overt aspects. a. Backdating b. Invigilation c. Graphology d. Iceberg e. Game
-
Strong Tool Company has been considering purchasing a new lathe to replace a fully depreciated lathe that will last 5 more years. The new lathe is expected to have a 5-year life and depreciation...
-
The owner of a plumbing supply company has requested a cash budget for June. After examining the records of the company, you find the following: a. Cash balance on June 1 is $1,486. b. Actual sales...
-
Using the check register below and the following bank statement, prepare a bank reconciliation for Lee.com. Note: Input all amounts as positive values. Round your answers to 2 decimal places. NUMBER...
-
The time for half-life period of a certain reaction A ? Products is 1 hour when the initial concentration of the reactant A is 2.0 mol L1, How much time does it take for its concentration to come...
-
How can a leader change? Identify at least three specific changes. How do the changes fit with your values? Include overcoming any resistance you might anticipate.
-
A company manufactures automobile tires. On July 15, 2023 the company sold 1,000 tires to the Grand car company for $50 each. The terms of the sale were 2/10, n/30. 1. What amount of sales revenue is...
-
A 29-year bond pays a quarterly coupon of 7% (compounded quarterly), on a face value of $2000. The bond's yield is 5% compounded quarterly. (a) Determine the price of the bond. Express your answer in...
-
how do major sporting evetns run through an event managers perspective?Explain
-
Consider a bond that pays a annual coupon of 14% (compounded annually) on a face value of $4500. Suppose that the bond was purchased for $11556.80, and that there are 20 coupons remaining. (a) Use...
-
Project L requires an initial outlay at t = 0 of $ 5 6 , 0 0 0 , its expected cash inflows are $ 1 2 , 0 0 0 per year for 9 years, and its WACC is 1 0 % . What is the project's payback? Round your...
-
Give the structural formulas of the alkenes that, on ozonolysis, give: a. (CH3)2C=O and CH2=O b. Only (CH3CH2)2C=O c. CH3CH=O and CH3CH2CH=O d. O=CHCH2CH2CH2CH=O
-
For each of the following scenarios, determine whether the companys current backup procedures enable it to meet its recovery objectives and explain why: a. Scenario 1: Recovery point objective = 24...
-
Some accountants have advocated that a companys human assets be measured and included directly in the financial statements. For example, the costs of hiring and training an employee would be recorded...
-
1. Discuss the criteria to consider in specifying the structure and features of CGCs new system. 2. Identify the data that should be incorporated into CGCs new system to provide adequate planning...
-
Harris, Inc., paid a \($3\) dividend yesterday. If the firm raises its dividend at 5 percent every year and the appropriate discount rate is 12 percent, what is the price of Harris stock?
-
You are offered the opportunity to buy a note for \($12,800.\) The note is certain to pay \($2,000\) at the end of each of the next 10 years. If you buy the note, what rate of interest will you...
-
What is the value of a 15-year annuity that pays \($500\) a year? The annuitys first payment is at the end of year 6 and the annual interest rate is 12 percent for years 1 through 5 and 15 percent...
Study smarter with the SolutionInn App