3.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:

speed and storage

Explanation:

The pros and cons of both are mainly in regards to speed and storage. Due to linked lists elements being connected to one another it requires that each previous element be accessed in order to arrive at a specific element. This makes it much slower than an array-based implementation where any element can be quickly accessed easily due to it having a specific location. This brings us to the other aspect which is memory. Since Arrays are saved as a single block, where each element has a specific location this takes much more space in the RAM as opposed to a linked implementation which is stored randomly and as indexes of the array itself.

Array Implementation:

Pros: Much Faster and Easier to target a specific elementCons: Much More Space needed

Linked Implementation

Pros: Less overall space neededCons: Much slower speed.

Related Questions

B1:B4 is a search table or a lookup value

Answers

Answer:

lookup value

Explanation:

Write a program that reads in 10 numbers from the user and stores them in a 1D array of size 10. Then, write BubbleSort to sort that array – continuously pushing the largest elements to the right side

Answers

Answer:

The solution is provided in the explanation section.

Detailed explanation is provided using comments within the code

Explanation:

import java.util.*;

public class Main {

//The Bubble sort method

public static void bb_Sort(int[] arr) {  

   int n = 10; //Length of array  

   int temp = 0; // create a temporal variable  

   for(int i=0; i < n; i++){  

         for(int j=1; j < (n-i); j++){  

           if(arr[j-1] > arr[j]){  

               // The bubble sort algorithm swaps elements  

               temp = arr[j-1];  

               arr[j-1] = arr[j];  

               arr[j] = temp;  

             }  

         }            

         }  

        }

 public static void main(String[] args) {

   //declaring the array of integers

   int [] array = new int[10];

   //Prompt user to add elements into the array

   Scanner in = new Scanner(System.in);

   //Use for loop to receive all 10 elements

   for(int i = 0; i<array.length; i++){

     System.out.println("Enter the next array Element");

     array[i] = in.nextInt();

   }

   //Print the array elements before bubble sort

   System.out.println("The Array before bubble sort");

   System.out.println(Arrays.toString(array));

   //Call bubble sort method

   bb_Sort(array);  

               

   System.out.println("Array After Bubble Sort");  

   System.out.println(Arrays.toString(array));

 }

}

Other Questions