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

  Difference between multiple processes and multiple threads

What is the difference between multiple processes and multiple threads

  Calculate the order of delay in the above channel

Illustrate the satellite communication system and calculate the order of delay in the above channel.

  Multi-threaded programming in java using locks

Assignment on Multi-threaded Programming in Java Using Locks

  Trying to write it java first and then pseudo code

A popular diversion in the United States, "word find" (or "word search") puzzles ask the player to find each of a given set of words in a square table filled with single letters. Trying to write it java first and then pseudo code

  Writing a program that computes the average salary

The first programming project involves writing a program that computes the average salary for a collection of employees of different types. This program consists of four classes

  Credit card expenses

You started recording every credit card transaction so that you can analyze your monthly expenses. You used an Excel worksheet to track dates, places, categories, and amounts. Because you are a consultant who travels periodically, you also have bu..

  What are some of the differences in the sql

What are some of the differences in the SQL supported by RDBMS vendors?

  Have to implement a search algorithm

Suppose you have to implement a search algorithm in a high programming language such as Java or C++. You are given a linked list that is not sorted and it's rather small, in the order of a few dozen elements.

  Differences between black-box testing and white-box testing

Describe the differences between black-box testing and white-box testing. Which strategy do you feel to be more useful?  Why? (Name and describe at least one type of black or white box test as part of your discussion)

  Set of management functions

Suppose a system uses ACLs to maintain its protection matrix. Write a set of management functions to manage the ACLs when (1) a new object is created; (2) an object is deleted;

  Declare a string variable named empty

Declare a string variable named empty, and initialize it to the empty string.

  Ceate an application which represents a simplified course

create an application which represents a simplified course registration system using arraylists and hashmaps.define a

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