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
bezimeni [28]
3 years ago
7

Let T(n) denote the running time for the Sort-and-Count algorithm (below). Sort-and-Count(L) { if list L has one element return

0 and the list L Divide the list into two halves A and B (r1, A) = Sort-and-Count(A) (r2, B) = Sort-and-Count(B) (r3, L) = Merge-and-Count(A, B) r = r1+r2+r3 return r and the sorted list L } Assuming that Merge-And-Count(A,B) runs in time Al+IB| what is the recurrence for T(n)? T(n) = 2T(n/2)+1 T(n)=(n/2) + n T(n) = 2T(n-1) + 1 T(n) = Tỉn/2)+1 - T(n) = 2T(n/2) + n T(n) = 2T(n/2)+log n
Computers and Technology
1 answer:
butalik [34]3 years ago
7 0

Answer:

The answer is "\bold{T(n) = 2T(\frac{n}{2}) + n}"

Explanation:

Given:

The Merge-And-Count of (A,B) runs in time |Al+IB|

T(n) recurrence=?

Calculating the value of the recurrence:

\to  T(n) = T(\frac{n}{2}) + T(\frac{n}{2}) + f(|A| + |B|)\\\\  \therefore f(|A| + |B|) = n\\\\ \to T(n) = 2T(\frac{n}{2}) + n

You might be interested in
What will the following code display? int numbers[4] = { 99, 87 }; cout << numbers[3] << endl; a. 87 b.0 d. 34. What
pishuonlain [190]

Answer:

1. The output is 0

2. Each element in the array is initialized to 0.0

Explanation:

Solving (a): The output of the code

We have:

<em>int numbers[4] = { 99, 87 }; </em>

<em>cout << numbers[3] << endl;</em>

<em />

The first line initializes the 0 and 1 index of the array to 99 and 87, respectively.

Other elements will be 0, by default.

So, the following code segment will output 0

<em>cout << numbers[3] << endl; </em>

<em />

Solving (b): What the given code will do?

The first and second line declares an array of 5 elements

However, the following iteration will only initialize the array with 0.0 starting from the second

<em>for(int i = 2; i <= SIZE; i++) { x[i] = 0.0; }</em>

<em />

Because, the counter is initialized to start from the second index.

7 0
3 years ago
N = 645<br> A = N % 10 <br> N = N // 10 <br> A = A + N //10 <br> A = A + N % 10<br> A = ?
Paha777 [63]

Answer:

LOOK CORRECT THE ANSWER IS IN THE QUESTION A=? SO THE ASWER IS ?

8 0
3 years ago
________________are programs that designed to help users to be more productive with their personal tasks
Sergio039 [100]
Answer is • designers •

Have a nice day
7 0
3 years ago
Read 2 more answers
A program asks the user to enter the unit price of a chair and the quantity he is buying. It calculates and displays the total p
Shtirlitz [24]

Answer:

The c++ program for the given scenario is shown below.

#include <iostream>

using namespace std;

int main() {

   // variables declared for unit price, quantity, total price

// price is taken as double

// quantity is taken as integer

   double chair_price, total_price;

   int chair_qty;

   cout << " Enter the unit price of the chair : " << endl;

   cin >> chair_price;

   cout << " Enter the number of the chairs to be bought : " << endl;

   cin >> chair_qty;

   total_price = chair_price * chair_qty;

   cout << " The total price for " << chair_qty << " chairs is " << total_price << endl;

   return 0;

}

OUTPUT

Enter the unit price of the chair  

23.4

Enter the number of the chairs to be bought  

10

The total price for 10 chairs is 234

Explanation:

 

1. The variables for unit price, quantity of chairs and total price of chairs are declared. The reason for data type is explained below.

double chair_price, total_price;

   int chair_qty;

2. The variables are not initialized since their values is to be entered by the user.

3. First, the user is prompted to enter the unit price of the chair. This is stored in a double variable since price can be in decimals.

cin >> chair_price;

4. Next, the user enters the number of chairs to be bought. This value is stored in an integer variable since quantity can not be a decimal number.

cin >> chair_qty;

5. The total price is computed as the product of the unit price and the quantity of chairs. The total cost is also stored in a double variable since unit price can be in decimals.

total_price = chair_price * chair_qty;

6. Lastly, this total price is displayed to the standard output.

7. The keyword endl is used to insert new line.

4 0
3 years ago
An array whose elements you can access using a single subscript is a(n) ____ array
Svetlanka [38]
One-dimensional array.
3 0
4 years ago
Other questions:
  • Why isn't 802.1X a good choice for home based wireless networks
    5·1 answer
  • Damage to which portion of the limbic system results in loss of memory of recent events and difficulty committing anything new t
    13·1 answer
  • Reasons for the growth of decision-making systems include:
    13·1 answer
  • Your electric service has been failing with some frequency lately because of a lot of storms, and you are looking for more peace
    14·1 answer
  • Which changes should be made to establish and maintain formal writing conventions? Select two options.
    10·1 answer
  • ____ is the amount of effort (usually in hours) required to perform cryptanalysis on an encoded message so that it may be decryp
    8·1 answer
  • Which of the following domestic appliances does not use a magnet?
    10·2 answers
  • What does a blue painted curb mean?
    12·1 answer
  • Html code to hyperlink home.html​
    5·1 answer
  • Why is it important not to leave your personal information on a public computer?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!