Question

In: Computer Science

I need the following answered for an Operating Systems course Describe the order in which the...

I need the following answered for an Operating Systems course

Describe the order in which the elements of the A array are accessed in the rows() and columns() functions. What is the main difference?

Include the output of each run and show what the average throughput is

Is there a difference in the throughput or time required to execute “rows()” versus “columns()”? If there is a difference, explain the cause of the difference

Solutions

Expert Solution

Array:

  • Array is the part of the data structure.
  • Array is a collection of similar data elements.
  • It has same data type.
  • Array are stored in consecutive memory location.
  • Array element are accessed by index value.

The order in which the elements of the A array are accessed in the rows() and columns() functions:

Programe to access element of array by cloumn and row:

#include<iostream> 
using namespace std; 
int main() 
{ 
    int A[3][3] ={{1, 2, 3}, 
            {4, 5, 6}, 
            {7, 8, 9}};
    for (int i = 0; i < 3; i++)
    { 
        cout<<"\n";
        for (int j = 0; j < 3; j++) 
        { 
            cout<<"\t";
            cout << A[i][j]; 
        } 
    } 
    return 0;
} 

The Output of each run and show what the average throughput is:

By row:

  • when we run the programe first time it will print 1.
  • 2 time run it will print 2.
  • 3 time print 3. And so on

By column:

  • 1 time print 1.
  • 2 time print 4.
  • 3 time print 7. And so on.

Process:

Difference: " Showed in the process"

  • In row: The consecutive element are situated next row of each other.
  • In column: The consecutive elements are situated next to the column.

Time required to execute “rows()” versus “columns()” function:

Programe :

#include <stdio.h>                     /* Library files*/
#include <time.h>                          
#include <conio.h>
#define MAX 100                        /*define array capacity*/ 
 
int A[MAX][MAX] = {0};                 /* declaration of array*/
void row() {                           /* row function*/
  int i, j; 
  for (i = 0; i < MAX; i++) { 
    for (j = 0; j < MAX; j++) { 
     A[i][j]++; 
    } 
  } 
}                                      /* Ending of row function*/
 
void column() {                        /* column function*/
  int i, j; 
  for (i = 0; i < MAX; i++) { 
    for (j = 0; j < MAX; j++) { 
      A[j][i]++; 
    } 
  } 
}                                    /* ending of row function*/

int main() {                          /* main function*/
  int i, j; 
  clock_t t = clock(); 
  row(); 
  t = clock() - t; 
  printf("Row access time :%f s\n",  
                t / (float)CLOCKS_PER_SEC); 
  t = clock(); 
  column(); 
  t = clock() - t; 
  printf("Column access time :%f s\n",  
               t / (float)CLOCKS_PER_SEC); 
  return 0; 
} 

Output:

Here we can see the difference in time required to execute “rows()” versus “columns()” function Because the reason is same as diffrenece:

  • In row: The consecutive element are situated next row of each other so that it will took less time.
  • In column: The consecutive elements are situated next to the column so that it will took more time.

Note:- Excuation time depends on your system capacity.


Related Solutions

I need the following questions answered with an explanation. 1. Which of the following constitutes market...
I need the following questions answered with an explanation. 1. Which of the following constitutes market failure? The inability of markets to _____ a. internalize positive externalities b. internalize negative externalities c. Both a. and b. d. None of the above 2. When is the burden of an excise tax incidence equally shared between producers and consumers? a.The tax burden is always equally shared between producers and consumers. b. When the slope of the supply curve is steeper than the...
Need an outline for my healthcare systems course I want a universal Healthcare system in which...
Need an outline for my healthcare systems course I want a universal Healthcare system in which everyone is given health insurance in the United states in which the government insures everyone. Outline topic is Design a universal health care system for the United State system Here are the elements needed in the essay: Model the system after that of another nation, if you'd like, or design one that is completely original. Make sure to take into consideration that the values...
For the state of New Mexico and Colorado, I need the following questions answered please: a)...
For the state of New Mexico and Colorado, I need the following questions answered please: a) To what extent does New Mexico and Colorado follow the rulings of the Multistate Tax Commission? b) Does New Mexico and Colorado adopt pertinent changes to the Internal Revenue Code? If so, as of what date? c) Is the tax effectiveness of a passive investment company limited in some way? Has New Mexico and Colorado adopted the Geoffrey approach to the taxation of income...
I please need assistance with the following question " of this question partially answered: Question: Digital...
I please need assistance with the following question " of this question partially answered: Question: Digital Solutions, Inc., manufactures two component parts for the television industry:  Voltag... What price should Digital Solutions charge for the New Voltage Regulator, and what next steps should Digital Solutions take regarding the New Voltage Regulator? 7) Provide a recommendation given the case facts and your analysis. 8) Pay attention to detail within your answers in terms of spelling, grammar, and formatting.   see the...
I have A B and C answered I only need the answer to D and E....
I have A B and C answered I only need the answer to D and E. I have included the correct answers for A B and C Problem 8-41 (LO. 2, 3, 9) Lori, who is single, purchased 5-year class property for $200,000 and 7-year class property for $400,000 on May 20, 2016. Lori expects the taxable income derived from her business (without regard to the amount expensed under § 179) to be about $800,000. Lori wants to elect immediate...
I need more than just one question answered, please... 1. Which component of speech acts is...
I need more than just one question answered, please... 1. Which component of speech acts is the most difficult to determine? a. the linguistic form b. the context of the message c. the effect on the listener d. the intent of the message 2. If you tell a friend about a movie you watched the previous night, you would be engaging in a a. speech act. b. social register. c. narrative. d. conversation. 3. According to Bates, if a child...
1. In the Operating System zoo describe the 4 different types of Operating Systems and describe...
1. In the Operating System zoo describe the 4 different types of Operating Systems and describe them. 2. Describe what happens when booting a computer ? 3. What are System calls. Provide 6 file and directory system calls
Ch7/Financial Accounting Please, I need to get answered to the following:( 100 words for each part)....
Ch7/Financial Accounting Please, I need to get answered to the following:( 100 words for each part). 1. Describe physical controls, independent internal verification, and human resource controls. For each internal control principle, explain what weaknesses are being prevented for the company. 2. “Describe” the Ch6 – inventory turnover and days in inventory ratios. Explain the importance of each ratio and how each ratio assists the investor in evaluating a company’s performance.
i just need the national saving rate for the last two, b and c, I answered...
i just need the national saving rate for the last two, b and c, I answered everything else by myself and i just need the national saving for B and C In each part that follows, use the economic data given to find national saving, private saving, public saving, and the national saving rate. a. Household saving = 200     Business saving = 400      Government purchases of goods and services = 100      Government transfers and interest payments = 100      Tax collections...
I need with assignment develop an economic brief in which you address the following items: Describe...
I need with assignment develop an economic brief in which you address the following items: Describe the different types of economic systems and the role of government in economics Identify economic principles and their applications by interpreting diagrams and graphs Describe how trade impacts a specific industry Describe how government decisions can impact market outcomes Recognize industry related strategies to enhance economic efficiency 1. How does trade impact the goods and/or services that this industry provides? What economic principles for...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT