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
tatyana61 [14]
3 years ago
9

3-Write a program in some language that has both static and stack dynamic local variables in subprograms. Create six large (at l

east 100 * 100) matrices in the subprogram—three static and three stack dynamic. Fill two of the static matrices and two of the stack-dynamic matrices with random numbers in the range of 1 to 100. The code in the subprogram must perform a large number of matrix multiplication operations on the static matrices and time the process. Then it must repeat this with the stack-dynamic matrices. Compare and explain the results. (at least 5 lines)
Computers and Technology
2 answers:
shutvik [7]3 years ago
7 0

Answer:

Check the explanation

Explanation:

Code:

****************************************

import java.util.Random;

public class Matrices {

static int staticMatrix1[][] = new int [100][100];

static int staticMatrix2[][] = new int [100][100];

static int staticMatrix3[][] = new int [100][100];

public void localMatrices() {

int localMatrix1[][] = new int [100][100];

int localMatrix2[][] = new int [100][100];

int localMatrix3[][] = new int [100][100];

Random r = new Random();

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

for(int j =0;j<100;j++) {

localMatrix1[i][j] = r.nextInt(100);

localMatrix2[i][j] = r.nextInt(100);

}

}

long localStart = System.nanoTime();

multiplyLocal(localMatrix1, localMatrix2);

long localEnd = System.nanoTime();

System.out.println("Time taken for local multiplication: "+ (localEnd-localStart)/ 1000000);

}

public void multiplyLocal(int first[][],int second[][]) {

int[][] multiply = new int [100][100];

for (int c = 0; c < 100; c++)

{

for (int d = 0; d < 100; d++)

{  

int sum = 0;

for (int k = 0; k < 100; k++)

{

sum = sum + first[c][k]*second[k][d];

}

 

multiply[c][d] = sum;

sum = 0;

}

}

}

public static void multiplyStatic(int first[][],int second[][]) {

int[][] multiply = new int [100][100];

for (int c = 0; c < 100; c++)

{

for (int d = 0; d < 100; d++)

{  

int sum = 0;

for (int k = 0; k < 100; k++)

{

sum = sum + first[c][k]*second[k][d];

}

 

multiply[c][d] = sum;

sum = 0;

}

}

}

public static void main(String args[]) {

Random r = new Random();

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

for(int j = 0;j<100;j++) {

staticMatrix1[i][j] = r.nextInt(100);

staticMatrix2[i][j] = r.nextInt(100);

}

}

long staticStart = System.nanoTime();

multiplyStatic(staticMatrix1, staticMatrix2);

long staticEnd = System.nanoTime();

System.out.println("Time taken for static multiplication: "+ (staticEnd-staticStart)/ 1000000);

Matrices matrices = new Matrices();

matrices.localMatrices();

}

}

***************************************

Outputs:

Time taken for static multiplication: 6

Time taken for local multiplication: 12

******************************************

Sveta_85 [38]3 years ago
4 0

Answer:

See explaination

Explanation:

Code below:

import java.util.Random;

public class Matrices {

static int staticMatrix1[][] = new int [100][100];

static int staticMatrix2[][] = new int [100][100];

static int staticMatrix3[][] = new int [100][100];

public void localMatrices() {

int localMatrix1[][] = new int [100][100];

int localMatrix2[][] = new int [100][100];

int localMatrix3[][] = new int [100][100];

Random r = new Random();

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

for(int j =0;j<100;j++) {

localMatrix1[i][j] = r.nextInt(100);

localMatrix2[i][j] = r.nextInt(100);

}

}

long localStart = System.nanoTime();

multiplyLocal(localMatrix1, localMatrix2);

long localEnd = System.nanoTime();

System.out.println("Time taken for local multiplication: "+ (localEnd-localStart)/ 1000000);

}

public void multiplyLocal(int first[][],int second[][]) {

int[][] multiply = new int [100][100];

for (int c = 0; c < 100; c++)

{

for (int d = 0; d < 100; d++)

{

int sum = 0;

for (int k = 0; k < 100; k++)

{

sum = sum + first[c][k]*second[k][d];

}

multiply[c][d] = sum;

sum = 0;

}

}

}

public static void multiplyStatic(int first[][],int second[][]) {

int[][] multiply = new int [100][100];

for (int c = 0; c < 100; c++)

{

for (int d = 0; d < 100; d++)

{

int sum = 0;

for (int k = 0; k < 100; k++)

{

sum = sum + first[c][k]*second[k][d];

}

multiply[c][d] = sum;

sum = 0;

}

}

}

public static void main(String args[]) {

Random r = new Random();

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

for(int j = 0;j<100;j++) {

staticMatrix1[i][j] = r.nextInt(100);

staticMatrix2[i][j] = r.nextInt(100);

}

}

long staticStart = System.nanoTime();

multiplyStatic(staticMatrix1, staticMatrix2);

long staticEnd = System.nanoTime();

System.out.println("Time taken for static multiplication: "+ (staticEnd-staticStart)/ 1000000);

Matrices matrices = new Matrices();

matrices.localMatrices();

}

}

You might be interested in
Which advertising medium has the widest reach on a global front?
lesya [120]

Answer: B

The internet would allow businesses to easily expand globally with the help of social media and the ever expanding resources being poured onto the internet, reaching customers anywhere in the world.

8 0
3 years ago
1. Describe how research and development influence design. Cite specific examples of how research and development influence desi
vladimir1956 [14]

Answer:

so i research and found this,

Development is when findings of a research are utilized for the production of specific products including materials, systems and methods. Design and development of prototypes and processes are also part of this area. Engineering is utilization of these plans and research to produce commercial products.

4 0
3 years ago
pen the PT Activity. Perform the tasks in the activity instructions and then answer the question. Which event will take place if
zysi [14]

Answer:

Packets with unknown source addresses will be dropped.

Explanation:

This question is incomplete, we must add the number "1" in Fa0/1.

Which event will take place if there is a port security violation on switch S1 interface Fa0/1?

There are four options:

- A notification is sent.

- A syslog message is logged.

-The interface will go into error-disabled state.

- Packets with unknown source addresses will be dropped.

In this specific example, we have configured a security protection mode, if there is an unknown MAC address,  every package will be dropped.

We can configure in our switch with different Mac address, if there is not a MAC address in our configuration, the security mode will active, and we could receive any package.

5 0
3 years ago
What is a problem (worldwide or personal) that was solved by social media?
Zanzabum
You could write about any natural disaster, in which through social media they were able to raise funds to help those affected by said disaster
3 0
2 years ago
Match the following internet related terms to their definition
Luba_88 [7]

Answer:

1st buble goes to web address 2nd goes to browser 3rd goes to chat 4th goes to email

Explanation:

8 0
3 years ago
Other questions:
  • Which type of message format is designed to arouse curiosity, not showing the product or delivering quite enough information to
    10·1 answer
  • Uses of the following button in a keyboard: Prt SC, Home, Shift, Tab, Pg Up.​
    6·1 answer
  • Your baby brother has found the hammer and is eagerly eyeing one of the boxes. Describe and analyze an algorithm to determine if
    15·1 answer
  • Hank is the network administrator responsible for managing the web server cluster for an e-commerce company. He’s worried about
    9·1 answer
  • Creating an accurate inventory is a challenge, given the speed at which data files are created, deleted, moved, and changed. It
    12·1 answer
  • A simulation system is a technology that enables you to take over a customer’s screen, mouse, or other connected device in order
    13·1 answer
  • Each web site contains a(n) ____ page, which is the first document users see when they access the site.
    9·1 answer
  • JAVA
    5·1 answer
  • Define Rule Of Thirds
    9·1 answer
  • How to create a comparator generic type in java.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!