answer.
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]
2 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]2 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
Which of the following best reflects why lighting systems are used when filming on location outdoors? (Select all that apply.)
cupoosta [38]
<h2>All the given answers are right</h2>

Explanation:

  • Lighting is one of the key factor which is essential to do cinematography
  • It will help to cut off the shadows that is created using natural light
  • It can depict the mood of the scene that is shoot
  • We can adjust manually brightness and darkness according to the need, which is not possible in the natural light.
  • It can boost the quality of the footage
  • We can shoot anytime irrespective of the weather condition
  • The light from the camera alone is not enough to shoot the best picture
8 0
1 year ago
A file ____ includes the three or four characters that follow the dot in the filename and identify the files type.
vodka [1.7K]
A file extension includes the three or four characters that follow the dot in the file name
6 0
1 year ago
Read 2 more answers
You have enabled IPv6 on two of your routers, but on the interfaces you have not assigned IPv6 addresses yet. You are surprised
babymother [125]

Answer:

You have enabled IPv6 on two of your routers, but on the interfaces you have not assigned IPv6 addresses yet. You are surprised to learn that these two machines are exchanging information over those interfaces. How is this possible?

a. Due to anycast addressing

b. Due to ICMPv6

c. Due to the NATv6 capability

d. Due to the link-local IPv6 addresses

The correct answer is D. Due to the link-local addresses

Explanation:

LINK-LOCAL ADDRESS

Link-local addresses are addresses that can be used for unicast communications on a confined LAN segment.  The requirement with these addresses is that they are only locally-significant (i.e., restricted to a single LAN broadcast domain) and are never used to source or receive communications across a layer-3 gateway.

Typically, link-local IPv6 addresses have “FE80” as the hexadecimal representation of the first 10 bits of the 128-bit IPv6 address, then the least-significant 64-bits of the address are the Interface Identifier (IID).  Depending on the IID algorithm the node’s operating system is using, the IID may use either modified EUI-64 with SLAAC, the privacy addressing method (RFC 4941)), or the newly published Stable SLAAC IID method(RFC 8064).

When a host boots up, it automatically assigns an FE80::/10 IPv6 address to its interface.  You can see the format of the link-local address below. It starts with FE80 and is followed by 54 bits of zeros. Lastly, the final 64-bits provide the unique Interface Identifier.

FE80:0000:0000:0000:abcd:abcd:abcd:abcd

Link-local IPv6 addresses are present on every interface of IPv6-enabled host and router.  They are vital for LAN-based Neighbor Discovery communication.  After the host has gone through the Duplicate Address Detection (DAD) process ensuring that its link-local address (and associated IID) is unique on the LAN segment, it then proceeds to sending an ICMPv6 Router Solicitation (RS) message sourced from that address.

IPv6 nodes send NS messages so that the link-layer address of a specific neighbor can be found. There are three operations in which this message is used:

▪   For detecting duplicate address

▪   Verification of neighbor reachability

▪   Layer 3 to Layer 2 address resolution (for ARP replacement)  ARP is not included in IPv6 as a protocol but rather the same functionality is integrated into ICMP as part of neighbor discovery. NA message is the response to an NS message.  From the figure the enabling of interaction or communication between neighbor discoveries between two IPv6 hosts can be clearly seen.

3 0
2 years ago
A spreadsheet has some values entered: Cell A1 contains 10, cell A2 contains 14, A3 contains 7. You enter in cell A4 the followi
Mumz [18]
<h2>Answer: B</h2>

Explanation:

The value the play displayed in Cell A4 is 12 because the value in Cell A1 is 10. Since the equation for Cell A4 is A1+2, you replace 10 with Cell A1 to get 10+2. When you add 10 and 2 together, you get your answer of 12.

7 0
2 years ago
Before using the data type string, the program must include the header file ____.
notsponge [240]
Hello <span>Enriqueliz5443</span><span>

Answer: Before using the data type string, the program must include the header file string


Hope this Helps!
-Chris</span>
3 0
1 year ago
Other questions:
  • A circuit contains three resistors connected in parallel. The value of R1 is 2 K , the value or R2 is 6 K , and the value of R3
    5·1 answer
  • In a situation where handicapped person can only input data into the computer using a stylus or light pen, which keyboard config
    7·2 answers
  • Write a class with a constructor that accepts a String object as its argument. The class should have a method that returns the n
    13·1 answer
  • A computer has 4 GB of RAM of which the operating system occupies 512 MB. The processes are all 256 MB (for simplicity) and have
    11·1 answer
  • When a program has several modules calling other modules, programmers often use a program ____, which operates similarly to an o
    5·1 answer
  • You'd like to change the minimum password length policy in the Default Domain Policy group policy preference (GPO). What's the b
    10·1 answer
  • Allison wants to use equations to simplify the process of explaining something to the Sales team, but the default eq
    8·2 answers
  • Create a generic class Box with a type parameter that simulates drawing an item at random out of a box. This class could be used
    7·1 answer
  • Drag each tile to the correct box.
    12·1 answer
  • The Company management has asked that you compare the OSSTMM and the PTES to determine which methodology to select for internal
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!