Creates a temporary array as part of merging

Assignment Help JAVA Programming
Reference no: EM13919266

The textbook's Sorts.java merge() method creates a temporary array as part of merging, which is wasteful of computer memory. An alternative would be to store data to be sorted in a linked list rather than an array and to merge "in place" within the list. That is, the merge would be implemented by removing nodes from one part of the list and adding them to another part. Your assignment is to implement such a merge in the mergelist() method of the attached class MergeSortList.java. If your method is implemented properly, running the main method of MergeSortList should output a sorted list of numbers (the original version compiles and executes but outputs an unsorted list). Hints: Your new method should be similar in some ways to the merge() method contained in Sorts.java, with the major difference being that the new method will not use a temporary array. Instead, it should use the add(int index, E element) and remove(int index) methods of java.util.LinkedList to remove a node from one part of the list and add its info to a new node in another part of the list. Note also that the get(index i) method of LinkedList allows you to access elements of a LinkedList in much the same way you can access elements of an array using [i] notation. You'll need to be careful with how you update your method's indices (the mid, i2, and i3 variables from merge(); you won't need i1, since that indexed into the temporary array that you won't be using). Also, think carefully about what to do once one of the two lists being merged is empty; it might be easier to handle this than you would at first think!

Attachment:- MergeSortList.java.zip

Reference no: EM13919266

Questions Cloud

Depreciation on machinery : Depreciation on machinery is $940 for the accounting period.Interest incurred on a loan but not paid or recorded is $635.
What is optimal allocation of investment funds among stocks : What is the optimal allocation of investment funds among stocks, bonds, mutual funds, and cash? What is the annual rate of return and the total risk for the optimal portfolio?
Describe a situation where you negotiated a vendor contract : Describe your management style and how you motivate people on your team. Describe how you maintain relationships with vendors to ensure delivery and quality.
Divided by estimated overhead pool : The general formula to allocate cost is: a. estimated overhead cost divided by cost pool b. cost pool divided by estimated overhead pool c. cost to be allocated divided by total occurrences of the allocation base d. cost base divided by estimated ove..
Creates a temporary array as part of merging : The textbook's Sorts.java merge() method creates a temporary array as part of merging, which is wasteful of computer memory. An alternative would be to store data to be sorted in a linked list rather than an array and to merge "in place" within th..
Assignment on creating a use case : Refer to the RMO CSMS marketing subsystem shown in Figure 3-11 on page 79-80 of the textbook. Write a two to three (2-3) page paper in which you:
What is the balance in additional paid-in capital : The corporation issued half the stock for cash at $8 per share, earned $336,000 during the first three months of operation, and declared a cash dividend of $60,000. At the end of the year, what is the balance in additional paid-in capital?
Data about temperature and pressure for days : Problem:  Once launched a weather balloon can gather data about temperature and pressure for days.  During the day the sun will warm the helium in the balloon and the balloon will rise to a higher altitude.  At night, the helium will cool and the ..
What are the benefits of international standardization : What is ISO? What are the benefits of international standardization? How have the ISO 9000 standards been received worldwide? What are the latest changes in ISO 9000 (2000)? What are the basic principles of the latest revision to the ISO 9000 stan..

Reviews

Write a Review

JAVA Programming Questions & Answers

  Simple single-server queue has one line of waiting

simple single-server queue has one line of waiting customers and one server who wait on customers. suppose that

  What will unboxing do with null values

Java Question: Whatwill unboxing do with null values?

  Write a java method delete(key1, key2) to delete

1. Write a Java method delete(key1, key2) to delete all records with keys between key1 and key2 (inclusive) from a binary search tree.

  Implementation of encryption and steganography in java

This is a project report showing the essential details and coding structures related with the implementation of encryption techniques and steganography in JAVA.

  Method level comment

What type of information should be included in a method level comment?

  Create a 2-dimensional array for the volume of concrete

Your Company constructs concrete hemispherical domes that range in diameter from 40 to 90 feet and increments of 5 feet.

  Enhance the test score applicaion

Enhance the Test Score applicaion so it uses a "while" or a "do-while" loop plus a for loop - Change the while statement to a do-while statement, andtest this change. Does this work any better than the while loop?

  Sentence patterns and verb formulas

Provide the sentence pattern. Write out the sentence pattern - then write out the tense of the verb and provide the formula.

  Write a recursive program

Write a recursive program to compute the number of ways in which an integer k can be written as sum

  Write java program to enter number of marks

Write a java program called AverageMark.java. This program should allow the user to enter any number of marks and then display the minimum, maximum & average mark.

  Application named arithmeticmethods

Create an application named ArithmeticMethods whose main() method holds two integer variables. Assign values to the variables. In turn, pass each value to methods named displayNumberPlus10()

  Develop game using the concepts of cohesion

Develop any game of your choice using the concepts of Cohesion, Coupling and RDD, i.e., responsibility-driven design.

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