At what points Linear arrays and Linked Lists are given preferences with respect to each others? 

Use Linked Lists are given preferable over Linear Arrays when we have below mentioned scenario:
  • When we need a constant-time insertions or deletions from the linked list.
  • When we don't know in advance that, how many items will be in the list?
  • When we don't need any types of random access to any elements of the linked list.
  • When we want to insert elements in the middle of the linked list.

Use Linear Arrays are given preferable over Linked Lists when we have below mentioned scenario:

  • When we need random access to our data elements.
  • When the total number of elements inserted are known in advance, so that memory should be allocated in advance.
  • Array take less memory then Linked list. A completely filled linear array take less memory then linked lists.
  • When we need to access the data at any position at O(1).


Thanks
Mukesh Rajput
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments:

Thanks
Mukesh Rajput