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
shepuryov [24]
3 years ago
8

int foo(int A[], int left, int right){ int i, x, q, N; if(right <= left) return 1; x = 0; for(i=left; i <= right; i++) x +

= A[i] % 2; // busy work... N = right-left+1; q = left + (N/3); return x + foo(A, left, q) + foo(A, q+1, right);
Computers and Technology
1 answer:
sineoko [7]3 years ago
3 0

Answer:

quicksort.cpp

void quickSort(int arr[], int left, int right) {

     int i = left, j = right;

     int tmp;

     int pivot = arr[(left + right) / 2];

 

     /* partition */

     while (i <= j) {

           while (arr[i] < pivot)

                 i++;

           while (arr[j] > pivot)

                 j--;

           if (i <= j) {

                 tmp = arr[i];

                 arr[i] = arr[j];

                 arr[j] = tmp;

                 i++;

                 j--;

           }

     };

 

     /* recursion */

     if (left < j)

           quickSort(arr, left, j);

     if (i < right)

           quickSort(arr, i, right);

}

You might be interested in
We have written a method called sum with an int[] parameter nums. We want our sum method to compute the sum of nums, but our cod
ira [324]

Answer:

Following are the code to this question:

public class Main//defining a class-main  

{

public static int sum(int[] nums)//defining a method sum that accepts array  

{

int total = 0;//defining integer variable total

for(int num : nums) // use for-each loop

{  

total += num;//add array value in total variable

}

return total;//use return keyword to return the total value

}

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

{

int[] nums={1,2,3,4,5};//defining 1-D array nums

System.out.println(sum(nums));//use print function to call sum method  

}

}

Output:

15

Explanation:

In the class "Main", a static method, "sum" is defined, that accepts array in its parameter and inside the method, an integer variable "total" is define, that uses the for each loop to add array value in a total variable and use a return keyword to return its value.  

Inside the main method, an integer array nums are defined, that holds store some values and use the print function to call the sum method.

8 0
3 years ago
You would like to know how many cells contain data. Which function should you use?
Helga [31]
If we're talking about excel functions, A is your answer.

The COUNT function does exactly that (with modifications of it counting specific things e.g. COUNTA, COUNTIF, etc)

MIN returns the minimum value in the selected range.
SUM returns the sum of the values in the selected range.
ABS returns the absolute value of the selected cell.
6 0
3 years ago
¿Es lo mismo hablar de tecnología que de computadora?
V125BC [204]

Translation:  

Is it the same to talk about technology as about the computer?

5 0
3 years ago
What dose AUP stand for??????????
kipiarov [429]

Answer:

Acceptable Use Policy

Explanation:

A: Acceptable

U:Use

P:Policy

3 0
3 years ago
Read 2 more answers
Brian has created the following selection sort class in Java. In which line is the index of the smallest value returned? In whic
katen-ka-za [31]

Answer:

Explanation:

Since there are no line numbers in this question I will start counting from public class SelectionSort{ as line 1 and so on, as well as provide the code on that line.

The index of the smallest value is returned on line 8 where it says return min which shouldn't have any spaces and should be return minPosition;

The input array is given as an argument at the beginning of the function on line 2 where it says private static int positionMin (int] vals, int startPosition) {, as the variable vals.

This input array is also used as an argument on line 10 where it says Position; private static void swap(int] vals, int firstPosition, int secondPosition) and line 15 where it says vals[secondPosition] temp return public static void selSort(int| vals) {

8 0
3 years ago
Other questions:
  • The program prompts the user to interactively enter eight batting averages, which the program stores in an array. The program sh
    9·1 answer
  • In this story, the reader is strongly encouraged to believe that Skidmore is guilty of poisoning his brother Manchester. Explain
    6·1 answer
  • If r is an instance of the above Person class and oddNum has been declared as a variable of type boolean, which of the following
    8·1 answer
  • Which is the highest level of the hierarchy of needs model?
    7·2 answers
  • Once artwork is inserted into a placeholder, it can be moved around on a slide. True False
    9·1 answer
  • Can you make copies of classified documents provided you alert others?
    6·1 answer
  • Write the definition of a method min that has two int parameters and returns the smaller.
    9·1 answer
  • Select the correct answer.
    15·1 answer
  • What will be the results of the following code? final int Array_Size = 5;An error will occur when the program runs. There will b
    10·1 answer
  • Which two peripherals are not required to browse the internet?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!