The LinkedList collection class Assignment Help

Assignment Help: >> Java Collections Framework >> The LinkedList collection class

The LinkedList collection class:

This collection implements a list using the linked list approach. Each data item in the list is linked to the adjacent data items by storing a reference to those items. There is also a link from each data item to the previous data item. This is a dynamic collection, in that space is created for items as they are added to the list, so there is no limit to the size of such a list (unless the system runs out of memory completely).

Figure shows a representation of how items are stored in a linked list. The circles represent references to list items, so each list component contains both data and a reference to the next list component. The data items themselves must be objects, so in fact they are also references but, for clarity, we do not show this in Figure 11. The items head and tail shown are variables that store references to the first and last items in the list respectively.

1215_linklist collection class.png

The basic add operation for this collection class places the new item at the end of the list, so it becomes the last item. In Figure, the new data item is shown with diagonal hatching. The references stored by the old last item and by the tail variable are updated to refer to this new item. So linked lists are extensible data structures, but unlike ArrayLists, they use only as much memory as they need for their current data items.

8_linklist collection class1.png

The class LinkedList offers a wide range of methods, enabling it to be used to implement a number of other standard data structures, such as stacks and queues. Table lists some of the more important methods of this class.

370_linklist collection class2.png

Note the two overloaded add methods - recall that overloaded methods have the same name but a different signature because the number or types of their arguments are different. The first of these methods always adds to the end of the list. The other allows you to specify the index position where the new item is inserted - the list index starts at
0, the same as for Java arrays and ArrayList objects.

Similarly there are two remove methods, one specifying an index position, and the get and set methods, for accessing and updating list items, also specify an index position.

This choice of methods is typical of the Java Collections Framework - all lists (collections that implement the List interface) must offer these methods, but in most implementations some of the methods may be relatively inefficient. In the case of the LinkedList class, the methods that operate at a specified index are typically rather inefficient, since they must start at the head of the list and follow through all the linking references. A better way if you want to process a number of list items is to use an Iterator, as explained in the next subsection.

There are also 'convenience methods' particular to the LinkedList class, such as getFirst, getLast, addFirst, addLast, removeFirst and removeLast. These are 'convenience methods' in that we could easily program them in other ways, but they are convenient for these commonly required operations.

 

Java Assignment Help - Java Homework Help

Struggling with java programming language? Are you not finding solution for your The LinkedList collection class homework and assignments? Live The LinkedList collection class experts are working for students by solving their doubts & questions during their course studies and training program. We at Expertsmind.com offer The LinkedList collection class homework help, java assignment help and The LinkedList collection class projects help anytime from anywhere for 24x7 hours. Computer science programming assignments help making life easy for students.

Why Expertsmind for assignment help

  1. Higher degree holder and experienced experts network
  2. Punctuality and responsibility of work
  3. Quality solution with 100% plagiarism free answers
  4. Time on Delivery
  5. Privacy of information and details
  6. Excellence in solving java programming language queries in excels and word format.
  7. Best tutoring assistance 24x7 hours

 

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