• retagged by
963 views
0 0 votes

Consider an array $A=\left \{ 30,15,48,34,26,29 \right \}$

Let $X$ be the number of inversion of array $A,$ Now another array $B$ is constructed by making all the numbers in $A$ negative and keeping the order between each numbers same. Let the number of inversion of the modified array so obtained be $Y.$ Then $X+2Y=$_______________


$\left ( 30,26 \right )$ number of inversion $4$ or $1??$

2 Answers

Best answer
3 3 votes
The inversions in array $A$ are $(30, 15), (30, 26), (30, 29), (48, 34), (48, 26), (48, 29), (34, 26), (34, 29)$.

Number of inversions = $8$

The inversions in array $B$ are $(-30, -48), (-30, -34), (-15, -48), (-15, -34), (-15, -26), (-15, -29), (-26, -29)$.

Number of inversions = $7$

Therefore, $X = 8$ and $Y = 7$

$X + 2Y = 8 + 2*7 = 8 + 14 = 22$
• selected by
Answer:
Position:
Show:

Related questions

0 0 votes
1 1 answer
1.4k
1.4k views
aashish1406 asked Aug 9, 2023
1,438 views
Suppose we have a directed graph G = (V,E) with V= {1, 2, ..., n} and Eis presented as an adjacency list. For each vertex u in V, out(u) is a list such that (u, v) in {1,...
2 2 votes
1 1 answer
1.5k
1.5k views
aashish1406 asked Aug 9, 2023
1,459 views
You are given an array of elements where each array element represents the MAXIMUM number of jumps that can be made in the forward direction from that element. Now, consi...
0 0 votes
1 1 answer
1.4k
1.4k views
aashish1406 asked Aug 9, 2023
1,445 views
Numerical Answer Type Que?(please Try to give some ahortcut trick also or important concept is there to solve that question ) Suppose the hash function were instead $h(k)...
1 1 vote
1 1 answer
787
787 views
Piyush mishra asked Nov 25, 2018
787 views
Assume an array A[1,……..,n] has n elements, and every element of an array is less than or equal to n.An element is said to be “majority element”,if it is occured in more...