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
Anit [1.1K]
3 years ago
11

(3 points) Write a program to process two large chunks of data (e.g., a large 3D array and an array of self-defined structures w

ith each structure at least 256 Bytes) respectively. The array elements can be random. The process can be incrementing every element by 1 or others. Try different ways (e.g., stride-k reference, the loop orders or others) to traverse the array elements and simulate the program performance (i.e., running time). Note that you should record the time just before and after the data processing program, not including the data generation or other initiation programs. And you should calculate an average time of at least 5 experiments for each program.

Computers and Technology
2 answers:
QveST [7]3 years ago
6 0

Answer:

Check the explanation

Explanation:

#include <iostream> #include <chrono> using namespace std::chrono; using namespace std; struct X{ int a,b,c,d,e,f,g,h; }; int main(){ // 3D Array of integers 1000 x 1000 x 1000 int data1[10][10][10]; //Array of struct X struct X data2[10000] ; auto start = high_resolution_clock::now(); //stride 1 access data 1 Loop order 1: for(int i=0;i<1000;i++){ for(int j=0;j<1000;j++){ for(int k=0;k<1000;k++){ data1[i][j][k]; } } } auto stop = high_resolution_clock::now(); auto duration = duration_cast<microseconds>(stop - start); cout<<"3D array Stride 1 Loop Order 1"<<duration.count()<<endl; start = high_resolution_clock::now(); //stride 2 access data 1 Loop order 1: for(int i=0;i<1000;i+=2){ for(int j=0;j<1000;j+=2){ for(int k=0;k<1000;k+=2){ data1[i][j][k]; } } } stop = high_resolution_clock::now(); duration = duration_cast<microseconds>(stop - start); cout<<"3D array Stride 2 Loop Order 1"<<duration.count()<<endl; start = high_resolution_clock::now(); //stride 1 access data 1 Loop order 2: for(int i=0;i<1000;i++){ for(int j=0;j<1000;j++){ for(int k=0;k<1000;k++){ data1[j][i][k]; } } } stop = high_resolution_clock::now(); duration = duration_cast<microseconds>(stop - start); cout<<"3D array Stride 1 Loop Order 2"<<duration.count()<<endl; start = high_resolution_clock::now(); for(int i=0;i<10000;i++){ data2[i]; } stop = high_resolution_clock::now(); duration = duration_cast<microseconds>(stop - start); cout<<"Struct Array "<<duration.count()<<endl; }

Some Observations on the order:

<em><u>Stride 1 goes over all the elements of the array Hence takes more time than stride 2 which goes over alternate elements. </u></em>

<em><u>Loop order in the row major form takes leads time than column major form! </u></em>

<em><u>Struct array takes no time to execute because the structs are not being accessed.</u></em>

Check the code screenshot and code output in the attached image below.

anzhelika [568]3 years ago
3 0

Answer:

See explaination

Explanation:

#include <iostream> #include <chrono> using namespace std::chrono; using namespace std; struct X{ int a,b,c,d,e,f,g,h; }; int main(){ // 3D Array of integers 1000 x 1000 x 1000 int data1[10][10][10]; //Array of struct X struct X data2[10000] ; auto start = high_resolution_clock::now(); //stride 1 access data 1 Loop order 1: for(int i=0;i<1000;i++){ for(int j=0;j<1000;j++){ for(int k=0;k<1000;k++){ data1[i][j][k]; } } } auto stop = high_resolution_clock::now(); auto duration = duration_cast<microseconds>(stop - start); cout<<"3D array Stride 1 Loop Order 1"<<duration.count()<<endl; start = high_resolution_clock::now(); //stride 2 access data 1 Loop order 1: for(int i=0;i<1000;i+=2){ for(int j=0;j<1000;j+=2){ for(int k=0;k<1000;k+=2){ data1[i][j][k]; } } } stop = high_resolution_clock::now(); duration = duration_cast<microseconds>(stop - start); cout<<"3D array Stride 2 Loop Order 1"<<duration.count()<<endl; start = high_resolution_clock::now(); //stride 1 access data 1 Loop order 2: for(int i=0;i<1000;i++){ for(int j=0;j<1000;j++){ for(int k=0;k<1000;k++){ data1[j][i][k]; } } } stop = high_resolution_clock::now(); duration = duration_cast<microseconds>(stop - start); cout<<"3D array Stride 1 Loop Order 2"<<duration.count()<<endl; start = high_resolution_clock::now(); for(int i=0;i<10000;i++){ data2[i]; } stop = high_resolution_clock::now(); duration = duration_cast<microseconds>(stop - start); cout<<"Struct Array "<<duration.count()<<endl; }

Kindly check attachment for screenshot of the source code for proper indentation.

You might be interested in
Write a for loop that runs 5 times and accepts the input of an integer number every time. Those numbers will be accumulated by a
eduard

Answer:

import java.util.Scanner;

public class num2 {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       int total = 0;

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

           System.out.println("Enter next Int: ");

           total = total+in.nextInt();

       }

       System.out.println(total);

   }

}

Explanation:

In the code above written in Java programming language, the for loop statement for(int i=0; i<5; i++) ensures that the loop goes from 0-4 a total of five times.

At each iteration it requests a user to enter an int. The number entered is stored in the variable total which is initially assigned 0.

When the loop finishes execution, total is printed out

7 0
3 years ago
The goal of a system is to
andreyandreev [35.5K]

Answer:

The answer is option C, which is: perform a task

6 0
3 years ago
12. In 2009, __________ of all pedestrian fatalities were caused by impaired drivers
makvit [3.9K]
3% of pedestrian fatalities were caused by impaired drivers  
4 0
3 years ago
Read 2 more answers
F we are reduced to a set of computer algorithms, how do we differentiate ourselves from our programming or our connectome? is i
Goshia [24]

Answer:

Answer explained below

Explanation:

The surface biopsychology and the relatively new science of neuroinformatics are fascinating areas of study are the human brain is the most complex computer in existence. Understanding how it works has been a scientific endeavor for centuries combining the newest advances in computer programming with biochemistry computer modeling allows researchers to collect data and anticipate what may happen in a live brain helping them test and develop hypotheses that can be used in conjunction with experiments in the lab.

The reconstruction of neuronal morphology for simulation is difficult and time consuming, although recent advances in scientific software has somewhat simplified the process using the geometry preparation toolkit illustrates how the complex morphology of a neuron impacts the function of the cell Researchers are able to see the effects of the channels opening and the calcium being released both graphically and numerically.Adolescence involves sexual maturity in terms of hormones and physical development of the body.

The psychosocial context of adolescents is markedly different to that of children and adults Adolescents begin to assert more autonomous control over their decisions emotions and actions and start to disengage from parental control

  • Microchips are about the size of a grain of rice and coated with biocompatible glass upon implantation by syringe connective tissue should form to prevent migration.
  • The procedure is very low.

The current market for these devices includes livestock and laboratory animal industries though the technology is quite useful some problems have already surfaced although some of them tend to be identified with specific programs individuals or locations they are presented here as generic.he processes and methods that we use help determine the greater outcome of the venture,there is a unique quality about humans and that is the need for routine like animals humans too feel a sense of calm when falling into a pattern we are upended when we move to a new home or community when we transfer to a different school and when we change jobs even those who feel that they do not fit in as a quintessential member of society still experience the effects of routine.

That individual will have their process which contributes to the overall success of the group this also applies to education.One student may be inclined to study for seven hours before an exam and another may only study for two each possesses their routine.

  • Neuroinformatics leads us currently neuroscientists collect complex data in ever-increasing amounts fostering increased specialization with resultant challenges to integrate data between and across levels of interaction control and function the field should enhance its wealth of ever-increasing empirical data accumulated from its many disciplines and experimental approaches
  • The purpose of analyzing brain ultrastructure is to understand the normal synaptic communication pathway of neurons and supporting cellular elements and the alternations of such pathways and cellular elements caused by diseases.

6 0
3 years ago
java Two smallest numbers Write a program that reads a list of integers, and outputs the two smallest integers in the list, in a
SashulF [63]

Answer:

The code to this question can be defined as follows:

import java.util.*;//import package for user input

public class Main //defining a class

{

public static void main(String[] args)//defining main method  

{

   int m1,m2,num,t,i;//defining integer variable

   Scanner incx = new Scanner(System.in);//creating Scanner class object

   m1 = incx.nextInt();//input value

   m2 = incx.nextInt();//input value  

   if (m1 > m2)//use if block to check m1 greater than m2  

   {//swapping value

       t = m1;//holding m1 value in t

       m1 = m2;//defining m1 that take m2

       m2 = t;//holding m2 value  

   }

   for (i = 2; i < 6; i++)//defining for loop  

   {

       num = incx.nextInt();//input value  

       if (num < m1) //defining if block to smallest value

       {

           m2 = m1;//holding m2 value in m1

           m1 = num;//holding num value in m1

       }  

       else if (num < m2)//defining if block to smallest value  

       {

           m2 = num;//holding num value in m2

       }

   }

       System.out.println(m1 + " " + m2);//print two smallest values

   }

}

Output:

5

10

5

3

21

2

2 3

Explanation:

In the above code, five integer variable "m1, m2, num, t, and i" is declared, in which it creates the scanner class object for inputs the value and use m1 and m2 use to the input value.

In the next step, if a block is used to swap the value and pass into the for loop that use if block to find the two smallest values and hold its value into the m1 and m2 and print its value.

7 0
3 years ago
Other questions:
  • If you define CSS rules on a parent control, the rules will be inherited by all of the children widgets.
    12·1 answer
  • About n processes are time-sharing the CPU, each requiring T ms of CPU time to complete. The context switching overhead is S ms.
    12·1 answer
  • Select the correct answer. Linda has written a program that works well on various operating systems, but she needs to increase t
    10·1 answer
  • Implement a program to measure the impact of application-level buffer sizes on read time. This involves writing to and reading f
    13·1 answer
  • A cashier distributes change using the maximum number of five dollar bills, followed by one dollar bills. For example, 19 yields
    15·2 answers
  • Excel spread sheets are primarily used to
    13·2 answers
  • Why are computers better than humans at solving a problem like finding the shortest route between ten different cities?
    15·2 answers
  • Is monitor is a television​
    5·2 answers
  • (Please answer both parts, please)
    8·2 answers
  • STOP DELETING MY ANSWERS AND QUESTIONS!!!!!!!
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!