Create n bags n being the number of element in the array

Assignment Help Computer Engineering
Reference no: EM132196881

Write a class called Bag.java which will sort in ascending order an array arr[] of double from 0 to 1, using the following algorithm.

Indicate in comment, the Time Complexity of your algorithm.

1. Create n bags , n being the number of element in the array.

2. For every element of the array , put this element in a bag so that arr[ i ] is inserted into bag number n*arr [i] + 1 .

3. Sort each bags individually using the Selection sort.

4. Put all those values back in the array arr[] so that the array is now sorted.

Example :

Assume the array arr : 0.15 0.25 0.5 0.18 0.014 0.2 We have 6 elements, therefore 6 bags, which are filled as followed The elements in Bag 1 are sorted , as well as the element in Bag 2. The new sorted array is : 0.014 0.15 0.18 0.2 0.25 0.5

Note : This algorithm is a variation of the Bucket sorting algorithm.

Reference no: EM132196881

Questions Cloud

Ask the user to enter two integers n and m : Write C++ statements to repeatedly ask the user to enter two integers n and m, and print the sum of n and m. If the user enters 0 for both n and m, stop asking.
Involving extensive sharing of internal processes : What are the risks for both the supplier and the buyer when agreeing to enter into an exclusive relationship involving extensive sharing of internal processes.
Taylor is the founder of the behavioral school of management : Terminal values are beliefs that will never change in a person’s life. Taylor is the founder of the behavioral school of management.
What happens to the growth of output : Suppose the process of Brexit reduces immigration into the UK and assume that this re- duces the population growth rate. Examine what will be the effect.
Create n bags n being the number of element in the array : For every element of the array , put this element in a bag so that arr[ i ] is inserted into bag number n*arr [i] + 1 .
Change management contribute to organizational effectiveness : How does change management contribute to organizational effectiveness? Please provide a well-researched technical analysis.
Encapsulates statistics for summer job salaries for a group : Write a class (and a client class to test it) that encapsulates statistics for summer job salaries for a group of people over several years.
Calculate the free trade price ratio of each good : Calculate the free trade price ratio and aggregate production of each good in the trading equilibrium. How many units of wine does Home export?
Large multispecialty medical practice employing : You are the practice manager of Docs R Us, Ltd., a large multispecialty medical practice employing more than 100 physicians.

Reviews

Write a Review

Computer Engineering Questions & Answers

  What is the difference between string and stringbuilder

modify the week three javatm application using javatm netbeanstm ide to meet these additional and changed business

  Print the name and number of players in the game

Write a program that prints on separate lines, the name of your favorite book, its author, category, price, and total number of pages.

  Prepare an organization chart and communication plan

Prepare an organization chart and communication plan that outlines your team structure and communications within your team and the rest of the organization.

  Discuss the pros and cons of the two approaches

Discuss the pros and cons of the two approaches. The issues you should consider, among other& are efficiency (disk space and access time).

  Consider the reasons implementations fail for at least

1. consider the reasons implementations fail. for at least three of these reasons explain why this happens if there is

  Describe the steps required to implement an audit program

List and describe the steps and tasks required to implement an audit program. In addition, describe the audit class(es) that would be applicable to your.

  Generate and displays fibonacci sequence numbers

The program should be interactive and display the range of Fibonacci sequence given number n (eg. 500). in the languages Visual Basic and Java.

  Write initials in block characters to standard output device

Write your initials in block characters to a standard output device. Design your prototype using the symbol(s) of your choice.

  Write a function image that takes an image filename or url

Write a function image that takes an image filename or URL, and a width, then returns the correct img tag for displaying that filename with a given width.

  Capability maturity model (cmm) is in software development

For each level in your model, desribe how toidentify the maturity level and what steps are necessary to move to the next level. For each level, specify needs for relevant quality standards and quality management.

  Write a program that reads the data from the file mydata.txt

Write a program that reads the data from the file 'mydata.txt', saves it in an array of structures and finally prints the array of structures to the monitor.

  Create a short main() demonstration program

make two classes. The first holds sales transactions. Its private data members include date, amount of sale, and salesperson's ID number.

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