Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this assignment, you are required to specify and implement a Java class namded IntSortedList. The instances of IntSortedList are sorted lists of integers. There

In this assignment, you are required to specify and implement a Java class namded IntSortedList. The instances of IntSortedList are sorted lists of integers. There should be no limit on the length of the list. The operations on sorted lists of integers supported by IntSortedList are A default constructor that creates an empty list of integers. An operation named empty that determines if the sorted list is empty. The operation takes no argument and returns a Boolean value. An operation named length that returns the number of items on the sorted list. The operation takes no argument and returns a positive integer. An operation named insert that inserts an integer to the sorted list while maintaining its sorted-ness. The operation takes the integer to insert as its only argument. It should always succeed. An operation named delete that deletes an integer from the sorted list. The operation takes the integer to delete as its only argument. It returns true if the integer was in the sorted list. Otherwise, it returns false. Only one occurrence of the target is deleted by this operation. An operation named show that displays the integers in the sorted list on screen. Every row except the last one contains 8 integers separated by spaces. The last row may contain less than 8 integers.

You are required to provide a Linked List based implementation of IntSortedList and write a program that makes use of IntSortedList.

Follow the following steps. 1. Refine the above specification of IntSortedList by writing method prototypes for its operations and their pre/post conditions. 2. Write a class definition for IntSortedList. The only public methods in the class definition are those operations. The private members are instance variables that represent a sorted list of integers. Write an invariant on these instance variables as comments. You can have private methods that are auxiliary to public ones. 3. Write a program that reads from keyboard a sequence of positive integers that is ended with a negative integer. The positive integers are inserted into a sort list of integers when they are read. When the program finishes reading, it displays the following information on screen: (a) the number of positive integers that have been read; (b) the positive integers.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Marketing The Ultimate Marketing Tool

Authors: Edward L. Nash

1st Edition

0070460639, 978-0070460638

More Books

Students also viewed these Databases questions