COMPUTER SCIENCE AND ENGINEERING
DATA STRUCTURES
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
|
Array
|
|
Linked List
|
|
They are the same in terms of memory storage
|
|
None of the above
|
Detailed explanation-1: -Memory consumption is more in Linked Lists when compared to arrays. Because each node contains a pointer in linked list and it requires extra memory. Elements cannot be accessed at random in linked lists.
Detailed explanation-2: -More memory is required to store elements in linked list as compared to array. Because in linked list each node contains a pointer and it requires extra memory for itself.
Detailed explanation-3: -Memory space The doubly linked list holds two addresses in a node, one is of the next node and the other one is of the previous node; therefore, the space occupied by the two pointer variables is 8 bytes.
Detailed explanation-4: -Larger memory allocation: Unlike an array, each node within a linked list needs to store both its value and a reference to another node; therefore, it takes up more memory.
Detailed explanation-5: -A LinkedList consumes a bit more memory than an ArrayList since every node stores two references to the previous and next element. The insertion, addition, and removal operations are faster in a LinkedList because there is no resizing of an array done in the background.