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
Nastasia [14]
3 years ago
8

Recall the problem of finding the number of inversions. As in the text, we are given a sequence of n numbers a1, . . . , an, whi

ch we assume are all distinct, and we define an inversion to be a pair i < j such that ai > aj.
We motivated the problem of counting inversions as a good measure of how different two orderings are. However, one might feel that this measure is too sensitive. Let’s call a pair a significant inversion if i < j and ai > 2aj. Give an O(n log n) algorithm to count the number of significant inversions between two orderings.
Computers and Technology
1 answer:
Kay [80]3 years ago
5 0

Answer:

The algorithm is very similar to the algorithm of counting inversions. The only change is that here we separate the counting of significant inversions from the merge-sort process.

Algorithm:

Let A = (a1, a2, . . . , an).

Function CountSigInv(A[1...n])

if n = 1 return 0; //base case

Let L := A[1...floor(n/2)]; // Get the first half of A

Let R := A[floor(n/2)+1...n]; // Get the second half of A

//Recurse on L. Return B, the sorted L,

//and x, the number of significant inversions in $L$

Let B, x := CountSigInv(L);

Let C, y := CountSigInv(R); //Do the counting of significant split inversions

Let i := 1;

Let j := 1;

Let z := 0;

// to count the number of significant split inversions while(i <= length(B) and j <= length(C)) if(B[i] > 2*C[j]) z += length(B)-i+1; j += 1; else i += 1;

//the normal merge-sort process i := 1; j := 1;

//the sorted A to be output Let D[1...n] be an array of length n, and every entry is initialized with 0; for k = 1 to n if B[i] < C[j] D[k] = B[i]; i += 1; else D[k] = C[j]; j += 1; return D, (x + y + z);

Runtime Analysis: At each level, both the counting of significant split inversions and the normal merge-sort process take O(n) time, because we take a linear scan in both cases. Also, at each level, we break the problem into two subproblems and the size of each subproblem is n/2. Hence, the recurrence relation is T(n) = 2T(n/2) + O(n). So in total, the time complexity is O(n log n).

Explanation:

You might be interested in
what is the greatest number of bits you could borrow from the host portion of a class b subnet mask and still have at least 130
Lina20 [59]

The greatest number of bits you could borrow from the host portion of a class b subnet mask and still have at least 130 host per subnet is 24.

<h3>What is a host bit?</h3>

Host bits are known to be the parts of an IP address that can state out a particular host in any subnet.

Note that whenever we take or borrow an host-bit, we can also double the number of subnets that we are said to create and as such, when we borrowing 2 host bits we can have 4 subnets.

Learn more about Bits from

brainly.com/question/19667078

6 0
2 years ago
Friedman (1999) argues that "we are wrong to base health promotion in all societies on a Western framework for human development
Dovator [93]

Answers with Explanation:

A. Give at least two reasons why he believes this.

Friedman believes that health promotion based on Western framework for human development<em> unfairly criticizes the other cultures in the society.</em> Western framework values intellectual and economic achievements alone, which then <em>results to putting a great expense on the other essential human qualities.</em>

B. What crisis does he believe is happening in the most economically developed countries?

The crisis that is happening in the most economically developed country is the <em>devaluing of the other aspects which other human beings value in terms of individuality or families.</em>

C. What does he recommend to improve the programming for adolescent health?

He recommends that if changes were to be implemented for adolescent's health, <u>these have to be properly assessed regarding their effect on the adolescent's development,</u> including his/her family and other social relationships. Next is to check whether<u> it doesn't conflict with the adolescent's culture in the community that he belongs</u>. If it does, then it is essential to change it or find <em>another way which fosters</em><em> </em><em>the same goal.</em>

7 0
3 years ago
Mrs. Jackson wrote a newsletter to the customers of her housecleaning business that included some organizational tips they could
nika2105 [10]
The correct answer is a. effective communication

- - -
Ineffective and barriers to communication are problems that make communication unclear. Workplace communication is at work or at a job. This is not a job newsletter for workers, but for people at home.
5 0
4 years ago
Read 2 more answers
discuss the advantages and disadvantages that Excel has in helping navigate databases, big data, and data analytics.
posledela

Answer:

 The main advantage of using the the excel that help in navigating the databases and helps in data analytics. It basically exploring huge information and databases are predominantly the information purging methods in exceed expectations which aides in preparing information in an expedient and proficient way.

The information purging procedure incorporate VBA macros or rotate tables, mapping instruments, report causing utilizing progressed to exceed expectations devices and furthermore has the upside of reconciliation with different virtual products.

The disadvantage are as follows:

  • It is difficult for sharing the spreadsheet in the system.
  • It also face difficulty while observing the any type of the regular tends in the given data.

5 0
3 years ago
In risk management what does risk evaluation involved
VLD [36.1K]

Answer:

Explanation:Risk management is the decision-making process involving considerations of political, social, economic and engineering factors with relevant risk assessments relating to a potential hazard so as to develop, analyze and compare regulatory options and to select the optimal regulatory response for safety from that hazard.

5 0
3 years ago
Other questions:
  • Which two jobs have high demand need for practitioners( have a skill shortage)
    13·1 answer
  • Peter accumulated many photos from his visit to Wisconsin. He wants to upload these photos to a social networking site. Which fi
    12·1 answer
  • The GaVS resource where students can locate information regarding Canvas, student email, registration and O365 is called the: St
    6·1 answer
  • 5. If you are 16 to 20 years old, you are __________.
    14·1 answer
  • How to transfer photos from lg tablet to computer?
    15·1 answer
  • Imagine you are building an ATM system; list at least 6 application domains for the system. That is, in which context is the sys
    13·1 answer
  • What is an undirected graph?
    13·1 answer
  • Decimal numbers is equivalent to binary 110
    5·1 answer
  • Select the correct term to complete the sentence.
    7·1 answer
  • Which work habits should you follow to increase work efficiency and avoid health issues?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!