Write a nodups() method for the higharray class

Assignment Help JAVA Programming
Reference no: EM131604469

Programming Projects

To the HighArray class in the highArray.java program (Listing 2.3), add a method called getMax() that returns the value of the highest key in the array, or -1 if the array is empty. Add some code in main() to exercise this method. You can assume all the keys are positive numbers.

Modify the method in Programming Project 2.1 so that the item with the highest key is not only returned by the method, but also removed from the array. Call the method removeMax().

The removeMax() method in Programming Project 2.2 suggests a way to sort the contents of an array by key value. Implement a sorting scheme that does not require modifying the HighArray class, but only the code in main(). You'll need a second array, which will end up inversely sorted. (This scheme is a rather crude variant of the selection sort in Chapter 3, "Simple Sorting.")

Modify the orderedArray.java program (Listing 2.4) so that the insert() and delete() routines, as well as find(), use a binary search, as suggested in the text.

Add a merge() method to the OrdArray class in the orderedArray.java program (Listing 2.4) so that you can merge two ordered source arrays into an ordered destination array. Write code in main() that inserts some random numbers into the two source arrays, invokes merge(), and displays the contents of the resulting destination array. The source arrays may hold different numbers of data items. In your algorithm you will need to compare the keys of the source arrays, picking the smallest one to copy to the destination. You'll also need to handle the situation when one source array exhausts its contents before the other.

Write a noDups() method for the HighArray class of the highArray.java program (Listing 2.3). This method should remove all duplicates from the array. That is, if three items with the key 17 appear in the array, noDups() should remove two of them. Don't worry about maintaining the order of the items. One approach is to first compare every item with all the other items and overwrite any duplicates with a null (or a distinctive value that isn't used for real keys). Then remove all the nulls. Of course, the array size will be reduced.

Attachment:- Java.rar

Reference no: EM131604469

Questions Cloud

Create a summary of the students activities : you will need variables to store the number of times the student engaged in each activity. The summary might be created in app.java after the for loop
What price should you be willing to pay for this bond : Consider a non-callable bond with 5 years to maturity and an annual coupon of 4%. What price should you be willing to pay for this bond?
What factors contribute to the yearly incidence : What factors contribute to the yearly incidence and mortality rates of various cancers in Americans?
Define the diagnosing and treatment of personality disorders : Identify and describe the ethical issues associated with the diagnosing and treatment of personality disorders
Write a nodups() method for the higharray class : Write a noDups() method for the HighArray class of the highArray.java program (Listing 2.3). This method should remove all duplicates from the array.
Define the lagrange multipliers in multivariable calculus : In many applications, we want to maximize or minimize some quantity subject to a condition. Such constrained optimization problems are solved.
Summarize the concept of spaced repetition : Summarize the concept of spaced repetition and explain its relationship to learning
Community-based volunteer health organization : In 2014 The American Cancer Society began a partnership with Stand Up To Cancer to help fund additional research for lung cancer and developing new therapies.
Explain what type of stalker does this typify : What type of stalker does this typify, Should your friend contact the police

Reviews

Write a Review

JAVA Programming Questions & Answers

  Explain getters and setters in java

A constructor will allow a name and a new, validated subject code to be provided when a new subject is created.

  Infix expression and translate it to a postfix expression

program below is suppose to take in a infix expression and translate it to a postfix expression, but I need a way for the user to be able to input the expression using a scanner and output the postfix.

  Find the definition of the n-puzzle problem

Write a program to solve the 8-puzzle problem using the Depth-first search algorithm. Find the definition of the n-puzzle problem

  Delete a random element from an arraylist

Elements in an ArrayList and picking one at random to remove. Unfortunately, this slow, since deleting a random element from an ArrayList is slow because of all the shifting. For this question, you should modify the poll()method so that it runs in..

  Develop a set of classes for a college

Person: A Person contains a first name, last name, street address, zip code, and phone number. The class also includes a method that sets each data field and display method that displays all of a Person's information.

  Elements in a two-dimensional array

Write a value-returning method that returns the number of columns with n elements in a two-dimensional array of chars, where n is a parameter of the method. Include code to test your method.

  Write a method that takes two strings as parameters

Write a method that takes two Strings as parameters and returns true if the second String is the reverse of the first String. Otherwise it should return false.

  Write the code to complete lines

Provide the application that helps users to calculate the area - what is static members in data type class and how to write static methods

  Deadlock and starvation

What is the difference between deadlock and starvation.Explain in a sentence or two how you prevented deadlock in your implementation.

  Calculate the total cost incurred for all parts

You will also calculate the total cost incurred for all parts of the trip. For this project, you will use information from two different input files in order to calculate the trip plan and total cost.

  The implementation of a password checker

demonstrate knowledge of both exhaustive search of a problem space and lookup search through the implementation of a password checker.

  Define a static max method in the geometricobject class

Modify the GeometricObject class to implement the Comparable interface, and define a static max method in the GeometricObject class for finding the larger of two GeometricObject objects

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