What is the runtime of the following code segments? Prove that your answer is correct. 1. void foo(int* array, int size) { int sum = 0; int product = 1; for (int i=0; i


What is the runtime of the following code segments?  Prove that your answer is correct.


1.


void foo(int* array, int size)


{


  int sum = 0;


  int product = 1;


  for (int i=0; i < size;="">


  {


    sum += arrray[i];


   }


 for (int i =0; i < size;="">


 {


    product *= array[i];


  }


 cout < sum="">< "="" ,"=""><>


}




2.


void printPairs ( int * array, int size) {


   for (int i=0; i


   for (int j=0; j < size;="">


     cout < array[i]="">< "="" +="" "=""><>


}



3.


void reverse(int * array, int size) {


for (int i=0; i


 {


   int other = size - i-1;


   int temp = array[i];


   array[i] = array [other];


  array[other] = temp;


}


}



Jun 03, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here