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
Which is a feature of a strong thesis statement?
inessss [21]
A strong thesis statement should answer, but not elaborate on your opinion, or the facts of the central question.
6 0
3 years ago
Wanna play pubg<br><br><br>ill send u my id​
Nikitich [7]
My sister would what’s your id
6 0
3 years ago
Read 2 more answers
Write a program that reads in two integers typed on the keyboard and outputs their sum, difference, and product.
dsp73
# Written in python

a = int(input("Enter an integer: "))
b = int(input("Enter an integer: "))

sum = a + b

# subtract the smaller number from the bigger
if a < b:
    dif = a - b
else:
    dif = b - a

prod = a * b

print("The sum is", sum)
print("The dif is", dif)
print("The product is", prod)
6 0
3 years ago
In python, sorry if it’s blurry
stepan [7]

Answer:

nice

Explanation:

3 0
2 years ago
Read 2 more answers
You have recently been called to troubleshoot network connectivity problems at a user's workstation. You have found that the net
Verdich [7]

Answer:

The answer is "Pass the cable into the ceiling instead of over the floor".

Explanation:

Network access explains the complex process of link different parts of the network with each other, e.g. while using switches, routers, and access points, and whether, that system works.

  • To replace the cable with a pair cable graded in plenum, covered, twisted.
  • We use the cable to pass through the ceiling rather than through the concrete, eliminating the issue and stopping it from occurring again.
3 0
3 years ago
Other questions:
  • Don is the superintendent of the county school system. What task might Don
    8·1 answer
  • Consider that a large online company that provides a widely used search engine, social network, and/or news service is consideri
    12·1 answer
  • You have no control over who views your social network information
    13·2 answers
  • Given the scenario, before leaving the office, you ask the CIO to provide which formal document authorizing you to perform certa
    11·1 answer
  • The architecture in which the database resides on a back-end machine and users access data through their workstations is
    5·2 answers
  • PrimeFactorization.java: Write a program that begins by reading in a series of positive integers on a single line of input and t
    12·1 answer
  • Who is the first British in Europe ​
    10·1 answer
  • Which of the following is a key difference between a Windows 7 restore point and one you set yourself?
    11·1 answer
  • What is are the most efficient ways to make a slide presentation?
    12·2 answers
  • The concepts of ________________, _________________, and _________________ for covert acts are pivotal to understanding state-on
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!