Write a program that implements the distribution counting

Assignment Help JAVA Programming
Reference no: EM13936995

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 technique to count the number of inversion in the array. Describe briefly in a separate file how your divide-and-conquer algorithm works.

 

2. Given two lists of n integers A, B and a sum S, where all the elements in each list are unique, write a program that uses a transform-and-conquer algorithm with efficiency classT(nlogn) to decide whether there is an integer from A and an integer from B such that the sum of these two integers is equal to S.

 

For example, if A = {8, 3, 4, 7} and B = {5, 6, 12, 1} and S is 10, then your program should output "4 + 6 = 10" (where 4 is from A and 6 is from B)

 

Another example, if A = {1, 5, 4, 2} and B = {6, 3, 2, 1} and S is 9, then your program should output "No two integers from A and B add up to 9"

 

Describe briefly in a separate file how your transform-and-conquer algorithm works.Please note that a program using a brute-force algorithm with efficiency classT(n2) will NOT be marked.

 

3. Write a program that implements the distribution counting sort algorithm as discussed in class to sort a list of letters from a small set {a, b, c, d}. For example, the list contains b, a, c, c, d, d, a, your program should output a, a, b, c, c, d, d.

Reference no: EM13936995

Questions Cloud

Classify individual cost items into one of four categories : Classify the seven individual cost items into one of the four categories of prevention, appraisal, internal failure or external failure. Give two examples of non-financial performance measures Zaccaria could monitor as part of a total-quality-co..
Find ratio of a''s chance of winning a prize : 'A' has three share in a lottery in which there are 3 prizes and 6 blanks' 'B' has one share in a lottery in which there is 1 prize and 2 blanks. Find ratio of A's chance of winning a prize to B's chance of winning a prizes.
What evolutionary line did mammals evolve from : What evolutionary line did mammals evolve from? What is convergent evolution? Give an example, What was the first bird? It has characteristics of birds and dinosaurs; what are they?
What is the probability that 2 first spheres : In a box there are 7 red spheres and 12 blue spheres. 2 spheres are taken without return. If the third sphere is red, what is the probability that 2 first spheres are blue ?
Write a program that implements the distribution counting : Write a program that implements the distribution counting sort algorithm as discussed in class to sort a list of letters from a small set {a, b, c, d}. For example, the list contains b, a, c, c, d, d, a, your program should output a, a, b, c, c, d..
Describe one organism found in the paleozoic seas : Describe how natural selection acted upon the peppered moth in England? What are two theories about why amphibians began to colonize land? What group did amphibians evolve from?
Explain the tree traversals in all orders : If the node 30 is deleted, the erase algorithm selects which node as the replacement node?
A ticket is drawn at random. : Tickets numbered 1 to 20 are mixed up and then a ticket is drawn at random. What is the probability that the ticket drawn has a number which is a multiple of 3 or 5?
Benefits of co-working and attract more membership : What can Banyule DigiDECL do to educate more people about the benefits of co-working and attract more membership? What can they do to clearly convey their point of difference? (Amy)

Reviews

Write a Review

JAVA Programming Questions & Answers

  You have in your program an arraylist which contains

you have in your program an arraylist that contains employee salaries double type in arbitrary order. you need to

  Write an application with three labeled text field

Write an application with three labeled text fields,one each for the initial amount of a savings account, the annual interest rate, and the number of years. Add a button "Calculate" and a read-only text area to display the balance of the savings acco..

  Describe the graphical coordinate system in java

Describe the graphical coordinate system in Java. Where is the origin? What units apply to the x,y coordinates? How would you use the Graphics class to draw a line between 2 specific points? Give an example

  Create an application that provides a solution

Create an application that provides a solution for problem 20.8 In addition to requirements specified in the description.

  Write a program counter.java that is a thread

Write a program Counter.java that is a Thread that counts up to a limit with random pauses in between each count.

  Write a program called inheritancetest java

Write a program called InheritanceTest.java to support an inheritance hierarchy for class Point-Square-Cube. Use Point as the superclass of the hierarchy. Specify the instance variables and methods for each class.

  Integrate the benefit class into the employee class

The objective of the lab is to modify the Employee class to demonstrate composition and a class interface. Integrate the Benefit class into the Employee class

  Which parts of the assignment were you not able to complete

Which parts of the assignment were you not able to complete fully? For each, explain why you were unable to complete this part and what steps you took to attempt to complete it. Give me as much detail as possible such that I may award partial cred..

  What is an example of a javascript framework in the

what is an example of a javascript framework? in the framework you have described what is an example of an application

  Create pipe-and-filter network that will read data stream

Create a pipe-and-filter network that will read the data stream in FlightData.dat file, convert the temperature measurements from Fahrenheit to Celsius, and convert altitude from feet to meters - How would this impact the key quality attributes of ..

  Write applet which reads five numbers-draw equivalent stars

Write the applet which reads five numbers (each between 1 and 30). For each number read, your program must design line containing that number of adjacent asterisks.

  Create java application to create and maintain contact list

Create a JAVA application to create and maintain a contact list - Create a database to store the contact information.

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