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

  Write a java program that prompts the user

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

  Prepare a mobile android app

The app should target Android and be written in Java, unless you have obtained prior permission from your instructor to target a different platform

  What is server-side and client-side scripting?

1. What is Server-side and Client-side scripting? Explain the differences between server-side and client - side scripting languages. Please provide 3 advantages and disadvantages of each. Please provide applicable references in APA style

  Working with numeric variables

Create a Java program for the following application. (it is in the second chapter of my Intro to "Java Programming" book (Murach 4th Edition)It involves1. working with numeric variables2.using the System.out object to print output to console

  Draw a scheduling chart to show how the i/o and cpu

Draw a scheduling chart to show how the I/O and CPU are allocated and compute the average turnaround times for the CPU-bound and I/O bound task. Use the following table to keep track of all events and Ready/Blocked (I/O) queues.

  Program that counts the number of occurrences of lowercase

Write a program that counts the number of occurrences of lowercase and uppercase vowels in entered lines of text. Use a two-dimensional array to store the vowel counts. The array's first column holds the counts for the lowercase vowels, and the secon..

  Java program by array

Write a program that reads in a file that contains one integer per line. Each integer represents one location in the image. Assume that there are 64 rows and 64 columns in the image

  Create a java class called student

Create a Java class called student with the following instance variables: private String studentName

  Write java program to find calories-conditional operator

Write down the answer for this program? Write down Java program (use Conditional (? Operator) which suggests number of calories a person must eat each day.

  Primary care-secondary care and tertitary care

Discuss the differences among primary care, secondary care, and tertitary care and the 6 C's of primary care

  Implements the measurable interface

Implement a class Quiz that implements the Measurable interface. A quiz has a score and a letter grade (such as B+).

  The data-centric java agricultural image storing application

Develop and test a specified a data-centric Java application. The required application is described in the Agricultural Image storing application- case-study

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