Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The following exercise deal with coding a LinkedList. - The methids you are writing are instance methods inside of LinkedList, so you can use the
The following exercise deal with coding a LinkedList. - The methids you are writing are instance methods inside of LinkedList, so you can use the Node class. - The LinkedList contains a Node
12. (15 points) Suppose we had a new type of LinkedList, called the SortedLinkedList, which is a linked list, but it keeps all the items in the list sorted. As a result, when we add an item to a SortedLinkedList, we don't provide an index, as the SortedLinkedList figures out where to put , the new item based on the values already in the list. Your task is is to complete the add method for a SortedLinkedList, shown below. This method inserts a new item into the SortedLinkedList in such a way that the list remains sorted. For example, if the list is [1,25] and we call add (4), the becomes [1.2.43]. For simplicity: . You can use either a singly or doubly linked list. . you can use <.>, and =_ to compare items, but if you remember how to use compareTo(), you can do so for extra credit. . You may not call the add(int index , E item) method. . You may not call the getNode() method (although you may rewrite it), public void add(E item)f
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started