COMPUTER SCIENCE AND ENGINEERING
DATA STRUCTURES
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
|
True
|
|
False
|
|
Either A or B
|
|
None of the above
|
Detailed explanation-1: -4.1. The insertion, addition, and removal operations are faster in a LinkedList because there is no resizing of an array done in the background.
Detailed explanation-2: -Arrays allow random access and require less memory per element (do not need space for pointers) while lacking efficiency for insertion/deletion operations and memory allocation. On the contrary, linked lists are dynamic and have faster insertion/deletion time complexities.
Detailed explanation-3: -Adding or removing elements is a lot faster in a linked list than in an array. Iterating sequentially over the list one by one is more or less the same speed in a linked list and an array. Getting one specific element in the middle is a lot faster in an array.
Detailed explanation-4: -LinkedList comes with some extra overhead in that each element must be wrapped in a node so it can contain references to prev and next. ArrayList performance issues come from having initialize a completely new backing array when the existing capacity has been reached and copy all elements to the new array.