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

  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..

  Create exception classes

First, create three exception classes named NumberHighException, NumberLowException, and NumberNegativeException. Both NumberHighException and NumberLowException should be directly subclassed from the Exception class, but NumberNegativeException s..

  Java program for line item application

This exercise explains you the process of testing and enhancing Line Item application. Open LineItemApp, Validator, Product, LineItem, and ProductDB classes that are in the c:java1.6ch06LineItem directory and review this code.

  Proper coding conventions required the first letter of class

The files must be called  (driver) (handles house variables and methods) Proper coding conventions required the first letter of the class start with a capital letter

  Implement a shopping cart class with user interface

project will be to implement a shopping cart class with user interface (UI) that contains main() in Net Beans. The UI class will be used to perform user input/output and to invoke the appropriate methods of shopping cart class. When your program star..

  Write a program that prompts the user to input three numbers

Write a program that prompts the user to input three numbers. This program should then output the numbers in nondescending order.

  Need usual internal node structure and constructor

Create a basic, generic DataTree class. As described, it will consist of a binary tree structure, and will need the usual internal node structure and constructor -  Write the other methods used in Section One of the commented-out test code in Main..

  Prepare an address book to save the complete information

Prepare an address book to save the complete information of the person - Define the class Address that can store a street address, city, state, and zip code. Use the appropriate methods to print and store the address.

  Prepare a point class that represents points

Prepare a Point class that represents points on an x, y axis. The data members should be doubles x and y plus an int value called count that represents the number of points presently instantiated

  Java application-tests random number generation abilities

Write a Java application which tests the random number generation abilities of Java. Random number generation is explained below.

  Implement a method with signature transfer

Implement a method with signature transfer(S, T) that transfers all elements from stack S onto stack T, so that the element that starts at the top of S is the first to be inserted onto T, and the element at the bottom of S ends up at the top of T...

  Write program that can be used to read an extract from a log

Write a program that can be used to read an extract from a log for one elevator and print the following statistics: the total \uptime", that is the total time the elevator was in service, Σ(tdown - tup) (in years).

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