Answered step by step
Verified Expert Solution
Link Copied!

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 head and tail(optional). - The LinkedList contains a method size() that returns the number of elements in the list. - The Node objects are singly-linked, and contain public variable next, which references the next node in the list. - you can use an Iterator if you want but you dont need to.

image text in transcribed

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

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

DB2 11 The Database For Big Data And Analytics

Authors: Cristian Molaro, Surekha Parekh, Terry Purcell, Julian Stuhler

1st Edition

1583473858, 978-1583473856

More Books

Students also viewed these Databases questions