CrazyEngineers
  • Advantages of linked lists over arrays?

    Dixsita

    Member

    Updated: Oct 24, 2024
    Views: 1.2K
    I wish to discuss the advantages of link-list over array? I've been referring to the basic C-programming books, but haven't been able to make anything out of it.
    0
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • dipen30

    MemberSep 15, 2009

    Re: Dfs

    1. Array size is fix and cannot change at run time,But in
    link list we can create memory accoring to requirement.

    2. In array we define but at the run time it is not used so
    in that case memory is waste.
    Are you sure? This action cannot be undone.
    Cancel
  • faizaan

    MemberSep 15, 2009

    Re: Dfs

    hi,
    when we declare an array than the contiguous memory is allocated for that by compiler
    so to declare a array of given size we require contiguous free space .But in case of linklist
    we do not require contiguous free space each element will contain pointer that will give address of next free location.so linklist uses memory more wisely .
    Are you sure? This action cannot be undone.
    Cancel
  • Kaustubh Katdare

    AdministratorSep 15, 2009

    Dixsita
    Advantages of linklist over array??😕
    Always provide a better title to your discussion threads.

    *title edited*
    Are you sure? This action cannot be undone.
    Cancel
  • Saandeep Sreerambatla

    MemberSep 15, 2009

    Faizaan is exactly correct.

    Moreover, just try to write a program which sorts 5 elements of array using some method of sorting , like selection, merge, quick etc.

    Then consider these 5 elements as linked lists and try sorting it , then you will get fewer combinations.

    So effeciency is increased using Linked lists.
    Are you sure? This action cannot be undone.
    Cancel
  • yash.kumar

    MemberSep 16, 2009

    1. the memory distribution in linked lists is not contiguous unlike arrays, i.e., the memory is taken from the space available anywhere, and then a link is set with the previous node. However, arrays don not have this feature, and the memory distribution should be contiguous.

    2. insertion and deletion in linked lists are easier than in arryas.
    for e.g.- consider the list-
    A--B--C--D--E----- so on
    now, to remove any element, we can delete it, and link the elements linked to it together:
    A--C--D--E--, B removed.
    Here , we do not change the index or the position of the elements, but we just change the links. Similar is the case with additon.
    However, in arrays, we have to change the index or the location each time we insert or delete any element.
    Are you sure? This action cannot be undone.
    Cancel
  • Sahithi Pallavi

    MemberSep 16, 2009

    yash.kumar
    1. the memory distribution in linked lists is not contiguous unlike arrays, i.e., the memory is taken from the space available anywhere, and then a link is set with the previous node. However, arrays don not have this feature, and the memory distribution should be contiguous.

    2. insertion and deletion in linked lists are easier than in arryas.
    for e.g.- consider the list-
    A--B--C--D--E----- so on
    now, to remove any element, we can delete it, and link the elements linked to it together:
    A--C--D--E--, B removed.
    Here , we do not change the index or the position of the elements, but we just change the links. Similar is the case with additon.
    However, in arrays, we have to change the index or the location each time we insert or delete any element.

    Good answer. these are the two main differences.





    WINNERS DONT DO DIFFERENT THINGS....THEY DO THINGS DIFFERENTLY........
    Are you sure? This action cannot be undone.
    Cancel
  • pushpen mahawar

    MemberSep 18, 2009

    Resizing or compressing an Array (removing ) takes linear time, Link lists are compressed and resized automatically, in constant time. Deleting would be the same speed, if you can live with "Null" elements in your array. If you have to compress the array afterwards, a list is your best bet.

    Arrays are good for random access and good for sequential access (both are in constant time). Linked lists on the other hand are constant for sequential, but linear for random access.

    The choice of which datastructure to use, depends entirely on the problem you're trying to solve.
    Are you sure? This action cannot be undone.
    Cancel
  • rajayya

    MemberSep 23, 2009

    Dixsita
    Advantages of linklist over array??😕
    In the linked lists data be connected int the form of chain.that means the head of the one node shud be connected the tail of the another node.The data can be accessed from any where in the list.
    In arrays data having the index and surely data can be accessed from 1st onwrds.
    Are you sure? This action cannot be undone.
    Cancel
  • rajayya

    MemberSep 23, 2009

    Re: Dfs

    Excuse me y don't u expand it.
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register