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

  Inheriting from the jframe class

What is the difference between inheriting from the JFrame class and using a JFrame member variable?

  Write a method compact that removes all zeroes

Write a program that reads a text file (compact.txt) and stores the integers in an array.  Your instructor will provide this text file.

  Computes the salaries for a collection of employees

The first programming project involves writing a program that computes the salaries for a collection of employees of different types. This program consists of four classes. The first class is the Employee class, which contains the employee's name and..

  Create to determine how much either joe or jim

What type of equation would you create to determine how much either Joe or Jim makes separately? What equation is needed in Java (ignoring the $ symbol)? What data type is needed need for this equation?

  Information from the user and prints a payroll statement

Write a program that accepts the following information from the user and prints a payroll statement

  Implement a third component of the compiler

To detect duplicate declarations using the same identifier, you call the method retrieveOneLevel. This method returns a pointer to the identifier entry if the identifier was declared before in the current scope and null otherwise.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  How to track password-cracking software

Imagine you are a digital forensic investigator for a healthcare organization. You learn from your internal information security department that an employee has been using password-cracking software to access confidential customer insurance inform..

  Java threads

This is an introductory assignment on Java synchronization. You will use Java Threads while learning more about concurrency and achieving atomicity using Java’s inbuilt mechanisms.

  How to read data in a link list

How to read data in a link list?

  Which weblogic property is used to control number of queued

Which WebLogic 4.5x/5.x property is used to control the number of queued requests inside the WebLogic server? When I try load *.jsp files, I see the source code of each JSP files in my browser, what is wrong?

  Creates an array with x randomly generted integer elements

Write a program DuplicateTester.java that prompts user for a posi- tive integer x and creates an array with x randomly generted integer ele- ments in range 0 to 9. Use a method with signature public static int[] removeDuplicates(int[] array); to remo..

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