1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Whitepunk [10]
2 years ago
9

sparse(compact) Description: A sparse matrix is a 2D matrix that has many zeros. Assume that for storage efficiency someone has

converted a sparse matrix into a compact 2D matrix with dimensions Nx3 where N is the number of non-zero items in the original sparse matrix. In each row of compact, the first column holds the value of a non-zero item of the sparse matrix, the second column holds the row that this item resides in the sparse matrix, and the third column holds the column that this item resides in the sparse matrix. Write a function that given a compact matrix it returns the original sparse matrix. Assume the last row and the last column of the sparse matrix contain at least one non-zero item. Parameters: compact (list of list of int). Return value: a sparse list of list of int Example: sparse([[3,1,2],[4,5,3]]) → [ [0,0,0,0], [0,0,3,0], [0,0,0,0], [0,0,0,0], [0,0,0,0],

Computers and Technology
1 answer:
barxatty [35]2 years ago
8 0

Answer:

Function sparse code is

def sparse(a):

rl = []

cl = []

for i in range(0,len(a)):

rl.append(a[i][1])

cl.append(a[i][2])

r = max(rl)

c = max(cl)

s = []

k = 0

for i in range(0,r+1):

s.append([])

for j in range(0,c+1):

if (i==a[k][1]) & (j == a[k][2]):

s[i].append(a[k][0])

k = k+1

else:

s[i].append(0)

return s

def main():

k = sparse([[3,1,2],[4,5,3]])

print(k)

if __name__ == '__main__':

main()

Explanation:

Please see attachment for output

You might be interested in
Which system provides an easier way for people to communicate with a computer than a graphical user interface (GUI)
Marta_Voda [28]
Answer: natural Language Processing

Explanation:

Natural Language Processing: It is a sub field of linguistics which is concerned with the interactions between Human and computer especially how to program computers to process and to understand large amounts of natural language data.
6 0
2 years ago
Thomas would like to know when is the best time of the season to plant his tomato seeds. Which type of informational reference s
kenny6666 [7]

In this question, the options are missing. Here is the complete question:

Thomas would like to know when is the best time of the season to plant his tomato seeds. Which type of informational reference should he use?

A. Encyclopedia

B. Atlas

C. Almanac

D. Any of these

The correct answer is Almanac

Explanation:

Knowing the season or month to plant specific seeds is a relevant factor that can determine whether a plant grows and thrives. Because of this Thomas needs accurate and complete information about the best time of the year to plant tomatoes. This information can be found in an almanac because almanacs include planting dates for different plants as well as weather forecasts and other important events that can affect agriculture. Moreover, this informational reference provides information about the current year, which makes it to be updated in the topics it covers.

4 0
3 years ago
The general syntax for the function prototype to overload the assignment operator = for a class is ____.a. friend className&
dsp73

Answer:

Option (B) is the correct answer to the following question.

Explanation:

Here, in the code "const" is the constant keyword which is used when we need that the value stored in that variable will never change.

The following option is correct because the assignment operator are those operator which initialize the value in the variable and overloading of the assignment operator would be as we use the other operators and also we could use them by creating the objects as we use in the copy constructor.

So, that's why the following option is correct.

4 0
3 years ago
The small, touch-sensitive area at the base of the keyboard on a notebook computer is known as a ________.
USPshnik [31]
Trackpad.

(Sheep sheep mr sheep meep)
8 0
3 years ago
Read 2 more answers
If every element of a list must beprocessed, a(n) __________is more efficient than a(n)______.
statuscvo [17]

Answer:

B - array; hash

Explanation:

Arrays store elements of the same data type in a list. Every element in the array is assigned a unique integer (starting at 0). You are able to access/process an element by using its assigned integer. Hashes are similar in the fact that they also store data. The difference is that each element is assigned an object type (instead of an integer), making it a collection of key pairs, as such you would typically not use this to process elements efficiently.

6 0
3 years ago
Other questions:
  • Which type babshshshhsshshhshshshhshs
    13·1 answer
  • What is the part of the computer system that receives inputs, directs those inputs to the processor, and redirects the processed
    14·1 answer
  • Word processing software allows users to do which of the following: format text design pages share documents mail merge document
    14·2 answers
  • A binary search can be performed only on ____.
    6·1 answer
  • What is the purpose of exporting your public key to the directory services server?
    11·1 answer
  • Which network could NOT carry commercial traffic?
    15·1 answer
  • The expressions in each part of an AND or OR expression use ________ evaluation; that is, they are evaluated only as much as nec
    9·1 answer
  • What is the description of a computer ram?
    7·1 answer
  • Write a flowchart and C code for a program that does the following: Uses a do...while loop. Prints the numbers from 1 to 10 with
    13·1 answer
  • Which key must be pressed in addition to clicking on a hyperlink for it to be followed?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!