cross popup-offer
Call Back
cross cross
logo

24x7 Support Available

call-back

To Get the Best Price Chat With Our Experts

chat now

In A Hurry? Get A Callback

Close Button
Signup/Login
Back All services Close Button

World's Leading Assignment Library

Continued assistance through writing and revision till final submission by the professional and experienced writers.

  • 10 subjects

  • 2,10,1000
    solved Questions

  • 500 Solved Questions
    Added Everyday

  • Download Solution
    in Seconds

1. (50 points) Let a[0..n-1] be an array of n distinct integers. A pair (a[i], a[j]) is said to be an inversion if these numbers are out of order, i.e., i < j but a[i] > a[j]. For example: if array a

Question Preview:

1. (50 points) Let a[0..n-1] be an array of n distinct integers. A pair (a[i], a[j]) is said to be an inversion if these numbers are out of order, i.e., i < j but a[i] > a[j].

For example: if array a contains the following numbers:
              &nbs...

View complete question »

Question Preview:

1. (50 points) Let a[0..n-1] be an array of n distinct integers. A pair (a[i], a[j]) is said to be an inversion if these numbers are out of order, i.e., i < j but a[i] > a[j].

For example: if array a contains the following numbers:
                     9, 8, 4, 5
then the number of inversions is 5. 
(inversions are 9 > 8, 9 > 4, 9 > 5, 8 > 4, 8 > 5)

Write a program that uses the divide-and-conquer technique to count the number of inversion in the array.

 

2. (50 points) Given two sets of n unique integers A and B, determine if A is equal to B, i.e., all the elements of A are in B. Write a program that uses a transform-and-conquer algorithm with efficiency class Θ(nlogn) to solve this problem. 

Example #1:    Enter the number of integers in the sets:  4

Enter the first set:  9 5 3 2

Enter the second set: 3 2 9 5

These two sets are equal.

 

Example #2:    Enter the number of integers in the sets:  6

Enter the first set:  1 4 3 2 8 6

Enter the second set: 1 3 9 4 6 8

These two sets are not equal.

Please note that a program using a brute-force algorithm with efficiency class Θ(n2) will NOT be marked.

 

 

 

View less »

Solution preview

Solution:
CountingInversion.java
import java.util.Scanner;
public class CountingInversion
{
/*
* This function continuously divides the array into two equal halves.
* Determine the number of inversions in each small sub array
* and then determine the total inversion count in the array
* This algorithm is similar to merge sort algorithm which uses divide and conquer
methodology

Get solution

whatappWhatsApp Order whatappWhatsApp Order

STAY UPDATED WITH LIVEWEBTUTORS

java assignment help

we provide assignment help melbourne

free turnitin report get free turnitin
Free turnitin

DMCA.com Protection Status © Livewebtutors. All Rights Reserved 2019

Arrow up