Array list and linked list are both Java collection Fran work (JCF) implementati
ID: 3760929 • Letter: A
Question
Array list and linked list are both Java collection Fran work (JCF) implementations of the interface list. However there are difference between the two implementation and it's important to know when to use one or the other data structure(A) present and discuss the difference between the two two classes and the indicate when it is recommended to use one or the other
(B) consider a real world problem/application which requires a list data type as support data structure and discuss whether you should use an array list or linkedlist implementations. Present the layout of the considered application class showing the instance variables and the relevant methods. No methods implementation body is required. You should only indicate method header showing accessibility, return type, method name and parameters. Array list and linked list are both Java collection Fran work (JCF) implementations of the interface list. However there are difference between the two implementation and it's important to know when to use one or the other data structure
(A) present and discuss the difference between the two two classes and the indicate when it is recommended to use one or the other
(B) consider a real world problem/application which requires a list data type as support data structure and discuss whether you should use an array list or linkedlist implementations. Present the layout of the considered application class showing the instance variables and the relevant methods. No methods implementation body is required. You should only indicate method header showing accessibility, return type, method name and parameters.
(A) present and discuss the difference between the two two classes and the indicate when it is recommended to use one or the other
(B) consider a real world problem/application which requires a list data type as support data structure and discuss whether you should use an array list or linkedlist implementations. Present the layout of the considered application class showing the instance variables and the relevant methods. No methods implementation body is required. You should only indicate method header showing accessibility, return type, method name and parameters.
Explanation / Answer
(A)
Differences between an Array list and Linked list:
(B)
Linked lists are preferable over arrays when:
a) You need constant-time insertions/deletions from the list (such as in real-time computing where time predictability is absolutely critical)
b) You don't know how many items will be in the list. With arrays, you may need to re-declare and copy memory if the array grows too big
c) You don't need random access to any elements
d) You want to be able to insert items in the middle of the list (such as a priority queue)
Arrays are preferable when:
a) You need indexed/random access to elements
b) You know the number of elements in the array ahead of time so that you can allocate the correct amount of memory for the array
c) You need speed when iterating through all the elements in sequence. You can use pointer math on the array to access each element, whereas you need to lookup the node based on the pointer for each element in linked list, which may result in page faults which may result in performance hits.
d) Memory is a concern. Filled arrays take up less memory than linked lists. Each element in the array is just the data. Each linked list node requires the data as well as one (or more) pointers to the other elements in the linked list.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.