What are the pros and cons of using a linked implementation of a sparse matrix, as opposed to an array-based implementation?

Answers

Answer 1

Answer:

Linked lists and arrays are both linear data structures but while an array is a collection of items that can be accessed randomly, a linked list can be accessed sequentially.

A sparse matrix contains very few non-zero elements. For example;

_                        _

|  0   0   3  0  6    |

|   0   5   0  0  4   |

|   2   0   0  0  0   |

|_ 0   0   0  0  0 _|

In the implementation of a sparse matrix, the following are some of the pros and cons of using a linked list over an array;

PROS

i.  Linked lists are dynamic in nature and are readily flexible - they can expand and contract without having to allocate and/or de-allocated memory compared to an array where an initial size might need to be set and controlled almost manually. This makes it easy to store and remove elements from the sparse matrix.

ii. No memory wastage. Since the size of a linked list can grow or shrink at run time, there's no memory wastage as it adjusts depending on the number of items it wants to store. This is in contrast with arrays where you might have unallocated slots. Also, because the zeros of the sparse matrix need not be stored when using linked lists, memory is greatly conserved.

CONS

i. One of the biggest cons of linked lists is the difficulty in traversing items. With arrays, this is just of an order of 0(1) since the only requirement is the index of the item. With linked lists, traversal is sequential which means slow access time.

ii. Storage is another bottle neck when using linked lists in sparse matrix implementation. Each node item in a linked list contains other information that needs to be stored alongside the value such as the pointer to the next or previous item.


Related Questions

Other Questions
what is the largest island in the caribbean If the number of bacteria in a colony doubles every 10 hours and there is currently a population of 300 bacteria, what will the population be 20 hours from now? There are only green pens and red pens in a box. there are 3 more red pens than green pens in the box. sheila is going to take at random two pens from the box the probability that sheila will take two pens of the same color is 17/35 work out two different numbers of green pens that could be in the box A Rosa le gusta jugar con su primo Eduardo utilizando nmeros. Rosa le plante encontrar dos nmeros que sumados den 15 y que el doble de uno de ellos sea igual al otro ms 3 unidades, De qu nmeros se trata? A skater on ice with arms extended and one leg out spins at 3 rev/s. After he draws his arms and the leg in, his moment of inertia is reduced to 1/2. What is his new angular speed Two intersecting lines l and m form an angle of 56 with each other. The reflection of a point (4, 1) along the line l followed by a reflection along line m will cause a ________ rotation. Question 18 options: A) 56 B) 112 C) 180 D) 28 : An Australian man on holiday in Germany finds that his walletcontains 700 AUD. If he changes the money at a bank howmany euros will he receive? How can you write arithmetic and geometric sequences using recursive and explicit formulas modeled in a real world context? 6th grade math , help me please :) You are developing the project charter for a new project. Which of the followingis NOT part of the enterprise environmental factors?A) Lessons learned from previous projectsB) The work authorization systemC) Government and industry standards that affect your projectD) Knowledge of which departments in your company typically work on projects The number of chromosomes during meiosis is incredibly important.why is that? Given the figure below, find the values of x and z. Part A: Explain why the x-coordinates of the points where the graphs of the equations y = 2x and y = 4x + 3 intersect are the solutions of the equation 2x = 4x + 3. (4 points) Part B: Make tables to find the solution to 2x = 4x + 3. Take the integer values of x only between 3 and 3. (4 points) Part C: How can you solve the equation 2x = 4x + 3 graphically? (2 points) PLez Answer 50 points A "laser cannon" of a spacecraft has a beam of cross-sectional area A. The maximum electric field in the beam is 2E. The beam is aimed at an asteroid that is initially moving in the direction of the spacecraft. What is the acceleration of the asteroid relative to the spacecraft if the laser beam strikes the asteroid perpendicularly to its surface, and the surface is not reflecting please helpppp As soon as possible question 1: 5 1/8 is 2/3 of what number? question 2: what fraction of 9 3/8 is 4 3/8? Square all the integers from 1 to 10 inclusive. Then, round each number to the nearest hundred. Finally, sum the numbers. What do you get? WILL GIVE BRAINLIEST THANKS AND 5 STARS... PLZ HELP What is the ratio of the Volume of the smaller pyramid to the larger pyramid From the equation, find the axis of symmetry of the parabola.y = 4x+ 32x+ 61a. x= 3x=-4C.b. X= 4d. X=-3