1. Become a Developer for CrazyEngineers - Apply NOW!

Advantages of linked lists over arrays?

Discussion in 'Computer Science | IT | Networking' started by Dixsita, Sep 15, 2009.

  1. Dixsita

    Dixsita Certified CEan

    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.
     
  2. dipen30

    dipen30 Certified CEan

    Engineering Discipline:
    IT
    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.
     
  3. faizaan

    faizaan Certified CEan

    Engineering Discipline:
    IT
    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 .
     
  4. Kaustubh Katdare

    Kaustubh Katdare Administrator

    Engineering Discipline:
    Electrical
    Always provide a better title to your discussion threads.

    *title edited*
     
  5. Saandeep Sreerambatla

    Saandeep Sreerambatla Moderator

    Engineering Discipline:
    Electrical
    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.
     
  6. yash.kumar

    yash.kumar Certified CEan

    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.
     
  7. Sada

    Sada Star

    Engineering Discipline:
    Computer Science

    Good answer. these are the two main differences.





    WINNERS DONT DO DIFFERENT THINGS....THEY DO THINGS DIFFERENTLY........
     
  8. pushpen mahawar

    pushpen mahawar Certified CEan

    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.
     
  9. rajayya

    rajayya Certified CEan

    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.
     
  10. rajayya

    rajayya Certified CEan

    Re: Dfs

    Excuse me y don't u expand it.
     

Share This Page