Create a sortedlist object reference

Assignment Help Basic Computer Science
Reference no: EM13495290

Code a doubly linked, sorted list (in ascending order). Each item of the list will just store an int.
You will need to code three classes: Node, SortedList, and GroupProject.
The Node class has three instance variables, all private:

  • an int, representing the value stored inside the Node
  • a Node (next)
  • another Node (previous)

The methods to code are: constructor (at least one), accessors, mutators.
The SortedList class is a doubly linked list, sorted in ascending order.
It has two instance variables, both private:

  • an int, representing the number of items in the list.
  • a Node, representing the head node in the list.

The methods are:

  • insert: this method takes one parameter, an int; it has a void return value.

• delete: this method takes one parameter, an int; it returns a boolean value. If we were successful in deleting the item (i.e., the value of the parameter was found in the list), then we return true; if we were not successful, then we want to output a message that the value was not found, and therefore, not deleted, and returnedfalse.

  • toString: this method takes no parameters and returns a String representation of the list.
  • Constructor (at least one), and accessors and mutators as appropriate.

All methods should keep the list sorted in ascending order.
The GroupProject class contains the main method; it should do the following:

  • create a SortedList object reference
  • insert successively the values 25, 17, 12, 21, 78, and 47 in the sorted list
  • output the contents of the sorted list using the toString method
  • delete from the sorted list the value 30, using the delete method (obviously, 30 will not be found)
  • output the contents of the sorted list using the toString method
  • delete from the sorted list the value 21, using the delete method
  • output the contents of the sorted list using the toString method

Your insert and delete methods should work properly in all possible scenarios: inserting in an empty list, inserting at the beginning of a list, inserting in the middle of a list, inserting at the end of a list, deleting from an empty list (cannot delete), deleting an item not in the list (cannot delete), deleting the first item in a list, deleting in the middle of a list, deleting the last item in a list.

 

Reference no: EM13495290

Questions Cloud

How to calculate the solubility of caso4 : The Ksp of CaSO4 is 4.93× 10-5. Calculate the solubility (in g/L) of CaSO4(s) in 0.500 M Na2SO4(aq) at 25 °C
Uml conceptual view and process view : UML Conceptual View and Process View
Use technology and information resources to research issues : Discuss the considerations for implementing an operating and database system. Recommend the optimum system, considering the types of revenue and expense transactions for this company.
Explain the zeeman effect is observed as a splitting : The Zeeman effect is observed as a splitting in the spectral lines of hydrogen in the presence of a magnetic field. What is the greatest number of lines that a single spectral line can be split into by a magnetic field? a)2 b)3 c)4 d)5 e)6
Create a sortedlist object reference : Create a SortedList object reference
Identify and analyze each of the preceding transactions : Prepare a list of accounts and their balances for Moonlight Bay at January 31, 2012. Reflect the recurring transactions for the month of January but not the necessary month-end adjustments.
Explain assuming no heat loss by the system : Assuming no heat loss by the system, what will be the final temperature when 84 g of water at 10.0oC are mixed with 67 g of water at 50.0oC
Keeping track of calculations manually : Explain the benefits of using Excel as opposed to keeping track of calculations manually
Extracting company''s data using web data extractor : Extracting Company's Data Using Web Data Extractor

Reviews

Write a Review

Basic Computer Science Questions & Answers

  What should you do return computer to an operational state

Because you can't see the display, you can't work with the system. What should you do return the computer to an operational state?

  What variables exist in memory just before the statement

During the execution of the program above, what variables exist in memory just before the statement "printf("a[0] = %d, b = %d\n", a[0], b);" executes, and what are their values?

  Write a program that reads three integers and print

Write a program that reads three integers and print "In order" if they are sorted in ascending order or descending order, or "not in order" otherwise. For example: 1 2 5 in order 1 5 2 not in order 5 2 1 in order 1 2 2 in order 5 1 2 not in order.

  Convert the following two''s complement to decimal numbers

Convert the following two's complement representations to decimal numbers (assume 5 bit numbers). a. 11101 b. 01111 c. 10011

  A relational database model

A relational Database Model allows database users to analyze data thoroughly.

  Expalining protocols essential in data communications

What is meant by protocol? Why are protocols essential in data communications?

  Compare time complexity of convolution with kernel

Compare the time complexity of convolution with a n x n kernel when using: direct convolution with the 2-D mask, and separable kernel.

  Main benefits of utilizing business intelligence software

One of the main benefits of utilizing business intelligence software is that it gives you information needed to run your business. Being able to look at what happened in the past can give management insight into what will probably happen in the futur..

  Design a module

Design a module, using pseudocode, named getNumber, which uses a reference parameter variable to accept an Integer argument. The module should prompt the user to enter a number and then store the input in the reference paramter variable.

  The load master for a freighter

The load master for a freighter wants to determine the mix of cargo to be carried on the next trip. The ship's volume limit for cargo is 100,000 cubic meters, and it weight capacity is 2,310 tons.

  Identify the make and model of one 1 laser printer and one

identify the specific manufacture and model of one 1 magnetic disk one 1 solid state drive and one 1 optical drive.

  Find and display the largest of a list of positive numbers

solve the problem by using raptor. Find and display the largest of a list of positive numbers entered by the users. The user should indicate that he/she has finished entering numbers by entering a 0.

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