Program that uses the divide-and-conquer technique

Assignment Help JAVA Programming
Reference no: EM131398034

Question 1. 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 techniqueto count the number of inversion in the array.

Question 2. Given two sets of nunique 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-conqueralgorithm 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.

Verified Expert

The solution file is prepared in netbeans which contain two programs.They are counting inversion using divide and conquer algorithm and second one check two sets elements are equal using transform and conquer algorithm. Both program outputs are attached here with program.

Reference no: EM131398034

Questions Cloud

What do the four parts of the christian biblical narrative : What do the four parts of the Christian Biblical Narrative (i.e., creation, fall, redemption, and restoration) say about the nature of God and of reality in relation to the reality of sickness and disease? From where would one find comfort and hop..
What are the disadvantages of cloud computing : What business benefits do cloud computing\ services provide? What problems do they solve?
Did lees surrender at appomattox magnanimity to the defeated : Based on the evidence presented in this chapter, did Lee's surrender at Appomattox and Grant's magnanimity to the defeated forces save the nation from a drawn-out guerrilla war, as some historians have argued? Or, as other scholars have suggested,..
What are the five principles of fair information practices : What are the five principles of Fair Information Practices? For each principle, describe a business situation in which the principle comes into play and how you think managers should react.
Program that uses the divide-and-conquer technique : Write a program that uses the divide-and-conquer technique to count the number of inversion in the array and Write a program that uses a transform-and-conqueralgorithm with efficiency class Θ(nlogn) to solve this problem.
Left ventricle to the arcuate artery : Using a textbook as necessary, list the major arteries through these pathways in a human: a. Blood as it travels from the left ventricle to the arcuate artery.
In what way or ways did the shift to agriculture lead : In what way or ways did the shift to agriculture lead to a fundamental change in either relationships among humans (i.e., social complexity) or humanity's position via-a-vie the natural world. This could be in a positive or negative way (or both).
Evaluate their effectiveness with respect to certain areas : Describe specific experimentation and observational methods that could be used within your discipline to gather data. Include your rationale. Evaluate their effectiveness with respect to certain areas within your discipline.
Eight-ounce glasses of lemonade : How many kcalories are in 4 eight-ounce glasses of lemonade? What would you recommend that she drink instead?

Reviews

inf1398034

3/10/2017 4:08:14 AM

You really composed the paper! Straightforward with enough points of interest and conveyed it before due date. I'm awed. Incredible specifically addressed every one of my inquiries and didn't miss a one.

Write a Review

JAVA Programming Questions & Answers

  Function searches all files specified on the command line

Write a program Find that searches all files specified on the command line and prints out all lines containing a reserved word. For example, if you call java Find ring report.txt address.txt Homework.java, then the program might print:

  Consider the problem of finding the position

Consider the problem of finding the position, p, of the last occurrence of a given number, x, in an array, A. We thus want a function FindLast(A,n,x) with precondition

  Questions of java programming

Write a program that opens a .txt, reads the contents of the file line by line, and prints the content of each line. To do this, you should use look up how to use the Buffered Reader class1. Remember to use the try and catch statements to handle e..

  Develop and re-wrap the trivial console application

COS30016/HIT3037 Programming in Java - Develop and re-wrap the trivial console application into a GUI Application which allows the users to perform similar operations as indicated in assignment 1 handout.

  Redesign the grading program as an object-oriented design

redesign the grading program as an object-oriented design. We will start with a simple Student class. The student will have a name, an id (as a String) and a set of grades (as doubles)

  Create a non-gui based java application

Create a non-GUI based Java application that calculates weekly pay for an employee. The application should display text that requests the user input the name of the employee.

  How to setup a program to respond to events

Discussing how to setup a program to respond to events from any one of these sources - How do you create the necessary listener class? How do you associate the listener object with the event source?

  Write a statement that writes both of their values

Given an interger variable i and floating-point variable f, write a statement that writes both of their values to standard output in the following format: i=value-of-i f=value-of-f.

  Determines the surface area and volume of a hemisphere

Write an application that reads determines the surface area and volume of a hemisphere and then calculates the radius given a surface area and volume.The first step is to read in the radius from the users and then calculate the surface area and vo..

  Review the given code fragment from arraybag class

Review the given code fragment from ArrayBag class below and answer the following: Explain each line in your own words: Write the header (signature) of the method that contains this code

  Program buttons that implements a window with three button

Proper coding conventions required the first letter of the class start with a capital letter and the first letter of each additional word start with a capital letter

  Java programming arrays

Write a Java application program that takes in user input from keyboard and calculate semester grade based on the scores. In this assignment, you are going to rewrite the program, instead of taking keyboard input, you will use dialog box to prompt..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd