Puedes seguirnos en

BUSCADOR

Engineering

The cons of array over a linked list

Array data structure is simple to use and it is supported by almost all programming languages. It is very simple to understand and time to access any element from an array is constant. An array element can be accessed by a[i], where ´a´ is a name of the array and i is the index.

Compiler maps a[i] to its physical location in memory. Address of a[i] is given by starting address of a + i* size of array elements in bytes. This mapping is carried out in constant time, irrespective of which element is accessed. Array data struture suffers from some severe limitations:

  • Size of an array is defined at the time of programming or compile time.
  • Insertion and deletion is time consuming.
  • Requires contiguous memory.

First, the size of an array has to be defined when the program is being written and its space is calculated during compilation of the program. This means that the programmer has to take a decision regarding the maximum size of data. If the actual amount of data stored is less than the maximum size, a good amount of memory will be waited and on the other hand a larger sample of data can not be handled. To avoid the linear cost of insertion and deletion, we need to ensure that the list is not stored contiguously, since otherwise entire parts of list will need to be moved.

Anuncio publicitario
Escrito por

Administrador de ENGGDRCAOS. Canal dedicado especialmente a la formación del estudiante que aspira a ser ingeniero. Todos los videos son Ingles. Apasionado del universo Apple, estudiante de Ingeniería y Gamer por vocación.

Publicidad

ARTÍCULOS RELACIONADOS

Engineering

Singly linked list is a type of list which uses dynamic representation rather than a much simpler and versatile static representation. Dynamic representation is...

Engineering

Maximum size of the queue is fixed at the time of compilation, when the queue is represented using an array, this causes wastage of...

Engineering

The linked list consist of a series of structures. They are not required to be stored in adjacent memory locations. Each structure consist of...

Engineering

Stack is a LIFO(Last in first out) structure. Stack can be represented using an one-dimensional array which can hold the elements of a stack....