ct parameter must be able to handle an input of null. • Methods such as Collections.sort that automatically sort a list may not be used. • The Set class shall reside in the default package. Recommendations There are deviations in program implementation that are acceptable and will not impact the overall functionality of the set class. • A minimum size (initial capacity) may be specified for the ArrayList object. • When elements are added, the ens
Types of Linked List
A sequence of data elements connected through links is called a linked list (LL). The elements of a linked list are nodes containing data and a reference to the next node in the list. In a linked list, the elements are stored in a non-contiguous manner and the linear order in maintained by means of a pointer associated with each node in the list which is used to point to the subsequent node in the list.
Linked List
When a set of items is organized sequentially, it is termed as list. Linked list is a list whose order is given by links from one item to the next. It contains a link to the structure containing the next item so we can say that it is a completely different way to represent a list. In linked list, each structure of the list is known as node and it consists of two fields (one for containing the item and other one is for containing the next item address).
In this project you will implement a Set class which represents a general collection of values. For this assignment, a set is generally defined as a list of values that is sorted and does not contain any duplicate values. More specifically, a set shall contain no pair of elements e1 and e2 such that e1.equals(e2) and no null elements. Requirements To ensure consistency among all implementations there are some requirements that all implementations must maintain. • Your implementation should reflect the definition of a set at all times. • For simplicity, your set will be used to store Integer objects. • An ArrayList object must be used to represent the set. • All methods that have an object parameter must be able to handle an input of null. • Methods such as Collections.sort that automatically sort a list may not be used. • The Set class shall reside in the default package. Recommendations There are deviations in program implementation that are acceptable and will not impact the overall functionality of the set class. • A minimum size (initial capacity) may be specified for the ArrayList object. • When elements are added, the ensureCapacity() method may be called to ensure that adding a new element can proceed. • The trimToSize() method can be used to maintain a constant capacity equal to the number of elements in the set. Set Class Methods There are many methods that one would expect to be supported in a set class. This section will describe the interface of the set class. Unless specified, you will have to implement all of the described methods. Constructors • Set() o Description: constructs a set by allocating an ArrayList. • Set(int size) o Parameters: size - the desired size of the set. o Description: constructs a set with an initial capacity of size. • Set(int low, int high) o Parameters: low – an integer specifying the start value of a range of values. high – an integer specifying the end value of a range of values. o Description: constructs a set of Integer objects containing all the inclusive values from the range low…high. The default size of the set must accommodate this mode of construction. Addition • boolean add(Integer o) o Parameters: o – element to be added to this set. o Description: if o is not in this set, o is added to this set. o Returns: TRUE if the element is successfully added to this set. FALSE if the element is not added to this set. • int add(Integer[] s) o Parameters: s – array of elements to be added to this set. o Description: adds all elements of s to this set. o Returns: the number of elements successfully added to this set. Removal • Integer remove(Integer o) o Parameters: o – element to be deleted from this set. o Description: if o is in this set, the element is deleted. o Returns: the object that will be removed from this set. If the element is not contained in this set, null is returned. • int remove(Set s) o Parameters: s – set of elements to be deleted from this set. o Description: deletes all elements of s from this set. o Returns: the number of elements successfully deleted from this set. Miscellaneous • boolean contains(Integer o) o Parameters: o – the element to be searched for in this set. o Description: determines whether the given element is in this set. o Returns: TRUE or FALSE whether o is in this set. • void clear() o Description: Removes all the elements from this set. • boolean isEmpty() o Description: determines whether this set contains any elements.
in java and can you a lot of comments in it thank you
Trending now
This is a popular solution!
Step by step
Solved in 2 steps