Monday, 29 January 2018

CS301 Gdb Solution File 2018

Linked lists have several advantages over arrays. Elements can be inserted into linked lists indefinitely, while an array will eventually either fill up or need to be resized, an expensive operation that may not even be possible if memory is fragmented. Similarly, an array from which many elements are removed may become wastefully empty or need to be made smaller.

On the other hand, arrays allow random access, while linked lists allow only sequential access to elements. Singly-linked lists, in fact, can only be traversed in one direction. This makes linked lists unsuitable for applications where it's useful to look up an element by its index quickly, such as heapsort. Sequential access on arrays is also faster than on linked lists on many machines due to locality of reference and data caches. Linked lists receive almost no benefit from the cache.

Another disadvantage of linked lists is the extra storage needed for references, which often makes them impractical for lists of small data items such as characters or boolean values. It can also be slow, and with a naïve allocator, wasteful, to allocate memory separately for each new element, a problem generally solved using memory pools.


Singly linked list date structure I all prefer to use to build required application. Searching of product should be efficient and application should take minimum possible memory. Because

  • It uses less memory per node (single pointer).
  • Complexity of insertion and deletion at a known position is O(n).
  • If we need to save memory and searching is not required, we use singly linked list.
  • If we know that an element is located towards the end section, e.g. ‘zebra’ still we need to begin from start and traverse the whole list.
  • It allows traversal only in one way.
  • A singly linked list is a linked list where the node contains some data and a pointer to the next node in the list.
  • Singly linked list can mostly be used for stacks

No comments:

Post a Comment