different list and array



    1. Could there be general differences between the data list and array types irrespective of the programming language? In particular, by way of access to elements?
    2. In Python, what's a "right" list -- list or tuple?
    3. Which of these structures requires more memory and under what conditions?


  • Strictly speaking, link list and range are different data structures that are not linked to a specific programming language.

    Massive

    Massive is a combination of single-type data that are continuously stored. Access to the element is performed on the index per unit O(1) - we're talking directly to the right area of memory.

    Linked list

    On average, access to an element on a linked list O(N) by overtaking the elements in search of the right. Methods of access to elements differ in implementation and from the programming language. Like Java in standard class. LinkedList depending on the situation, the passage of the elements may begin from the beginning and end of the list. The search for the element can be done both by index and by component.

    The link list requires large memory costs under other equal conditions by retaining the indexes on the following/former elements and features of internal implementation.

    As for Python: https://wiki.python.org/moin/TimeComplexity :

    Internally, a list is represented as an array; the largest costs come from growing beyond the current allocation size (because everything must move), or from inserting or deleting somewhere near the beginning (because everything after that must move).

    As I can see, internally list is a mass, tuple - similar.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2