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...
Please I need this to be done in Java, can I have it answered by anonymous...
Please I need this to be done in Java, can I have it answered by anonymous who answered my last question regarding java? Thank you You will need to implement a specific algorithm implementation to match the class definition AND implement a unit test using JUnit that conforms the specific naming convention. Algorithm: Inputs: integers m and n , assumes m and n are >= 1 Order is not important for this algorithm Local variables integers: remainder Initialize: No initialization...
I need this answered not using excel Given the following data, construct a material requirements plan...
I need this answered not using excel Given the following data, construct a material requirements plan which will result in 100 units of parent #1 (P1), at the beginning of week 6 and 200 units of parent #2 (P2) at the beginning of week 8: item parent quantity on-hand on order(due) Lead Time Order size P1 - - - - 1 Lot-for-Lot P2 - - - - 1 Lot-for-Lot A P1, P2 1,2 70 0 1 500 B P1, P2...
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 only need question C answered, but I provided the rest of the worksheet to use...
I only need question C answered, but I provided the rest of the worksheet to use as reference in order to do so. Q1. Jamie wants to forecast the number of students who will enroll in operations management next semester in order to determine how many sections to schedule. He has accumulated the following enrollment data for the past six semesters: SEMESTER STUDENTS ENROLLED IN OM 1 270 2 310 3 250 4 290 5 370 6 410 a (2...
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
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT