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]
3 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]3 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
A common and extremely useful feature of most online dictionaries is
choli [55]
A common and extremely useful feature of most online dictionaries is <em />interoperable browser.
4 0
3 years ago
Which of the following uses replication to Infect multiple computers?
Nikolay [14]

Answer:

Trojan horse

Explanation:

mostly all the above mentioned use replication to infect computers but the one that uses replication to invest multiple computers at a time is Trojan horse.

hope it helps .

3 0
3 years ago
Read 2 more answers
Need A girl to play wit I'm bored On xbox btw or just to talk too btw be at least 12​
attashe74 [19]

Answer:

im 13 and im a girl wassup

Explanation:

3 0
3 years ago
Read 2 more answers
Next, Nate wants to add a date placeholder to his template. First, he places his insertion point a line before the company place
Debora [2.8K]

Explanation:

When using programs such as Microsoft and other similar products, things have been made so easy, with so many features, that you can make your document look good and interesting. For the case of Nate, he wants to add a date placeholder to his template, and the best way to do this is simply to click on the INSERT tab on the ribbon.

5 0
4 years ago
Make the smallest
seraphim [82]

Answer:

<em>Whole Numbers:</em>

0000 0001 (Binary) --> 1 (Decimal)

<em>Real Numbers:</em>

0000 0001 (Binary) -->  0.00390635 (Decimal)

Explanation:

In general, the smallest nonzero number that can be displayed in binary that is a whole number is 1.  Consider that as you increase by 1 in the binary system starting from 0, you will have the following:

0000 0000 == 0

0000 0001 == 1 (Smallest nonzero)

0000 0010 == 2

0000 0011 == 3

... etc.

Notice the smallest value here is decimal 1.  With this in mind, you will need to "program" you Flippy Do Pro to display this value.  Alternatively, if you consider decimal numbers in binary with the Flippy Do Pro, you can have even smaller nonzero numbers.  Depending on where you decide to place the decimal, you can even have smaller nonzero values.

Let's assume that you say this is a fractional representation of binary on the Flippy Do Pro.  Then, you will say your decimal is infront of the display of the Flippy Do Pro, hence index 9 (which is not displayed).  From here, you will simply say the following:

0000 0000 == 0.0

0000 0001 == 0.00390635 (Smallest nonzero)

0000 0010 == 0.0078125

0000 0100 == 0.015625

... etc.

Note, in binary, as you move the value of 1 to the right of the decimal, you are doing (1 / 2^n), where n is the index value to the right of the decimal.

Hence, depending on if you are to consider just whole numbers or real numbers, the smallest value displayed can be different even though the number being displayed is still 0000 0001.

Cheers.

3 0
3 years ago
Other questions:
  • Side mirror using convex mirror or concave mirror?​
    5·2 answers
  • Tab stops are very useful when you want to A. align text into rows. B. add space between paragraphs. C. align text into columns.
    14·2 answers
  • Define a function below, sum_numeric_vals, which takes a single dictionary as a parameter. The dictionary has only strings for k
    12·1 answer
  • Please help me very important
    7·1 answer
  • Write a loop that sets newScores to oldScores shifted once left, with element 0 copied to the end. Ex: If oldScores = {10, 20, 3
    13·1 answer
  • Why are Quick Parts useful in an Outlook message?
    5·1 answer
  • What might be some challenges if you’re trying to design a product for someone
    14·2 answers
  • Select the correct answer.
    7·1 answer
  • Select all the correct answers.
    7·1 answer
  • Select the skill that matches the following definition.​
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!