Discussion Response – General Purpose Data Structures

 Please respond to the discussion posted below with a minimum of 150 words and use references. 

   There are several different types of lists that are commonly used in  Java. Amongst these are Arraylists, LinkedLists, and Vectors. Unlike  arrays, these list methods are dynamically sizable which makes them  extremely convenient to use. Also, only one data type can be stored per  array and lists can store multiple data in one list. Arraylists and  Vectors are not suitable for storing primitive data types and instead  must store all data as an object (TUI, n.d.).  The biggest differences  between these three methods are how they store and access elements.  These differences make them better and less suited for storing data in  specific scenarios. For instance, if you will be adding a lot of  elements but not doing a lot of searching then a LinkedList may be your  best bet. If you can predict scalability of data but still need a  dynamically sizable array that is searchable, then a Vector might be the  most useful. If memory usage is not paramount but you want a high  amount of search speed, then an ArrayList is an easy choice. To provide a  clearer picture of the differences, here are some examples of the code  of each method.

A  linked list is a type of list which in the context of programming means  that it is linear collection of elements whose order is determined by  the elements around it (Linked List, 2021). In linked lists, these  elements are known as “nodes” which each node pointing to the next  element in the set with a “head” node at the start of the list and a  “tail” or null node to end the list.  Vectors are synchronized, can increment 100% of its size is adding an  element exceeds capacity and can use both enumerator and an iterator  (Parahar, 2019). Like ArrayLists, they also keep insertion order.  Because memory increase is done in increment, this means that they are  more resource friendly than ArrayLists. Because they are synchronized,  only one thread can access a Vector at one time. Ultimately, these make  Vectors more memory friendly but slower than ArrayLists, but still  capable of better search functions than a LinkedLists. 

Tags: No tags