|  | 
|  | 1 | +# Lista doblemente enlazada | 
|  | 2 | + | 
|  | 3 | +_Lea esto en otros idiomas:_ | 
|  | 4 | +[_Русский_](README.ru-RU.md), | 
|  | 5 | +[_简体中文_](README.zh-CN.md), | 
|  | 6 | +[_日本語_](README.ja-JP.md), | 
|  | 7 | +[_Português_](README.pt-BR.md) | 
|  | 8 | +[_한국어_](README.ko-KR.md) | 
|  | 9 | + | 
|  | 10 | +En informática, una **lista doblemente enlazada** es una estructura de datos enlazados que consta de un conjunto de registros enlazados secuencialmente llamados nodos. Cada nodo contiene dos campos, llamados enlaces, que son referencias al nodo anterior y al siguiente en la secuencia de nodos. Los enlaces anterior y siguiente de los nodos inicial y final, respectivamente, apuntan a algún tipo de terminador, normalmente un nodo centinela o nulo, para facilitar el recorrido de la lista. Si solo hay un ganglio centinela, la lista se enlaza circularmente a través del ganglio centinela. Puede conceptualizarse como dos listas enlazadas individualmente formadas a partir de los mismos elementos de datos, pero en órdenes secuenciales opuestos. | 
|  | 11 | + | 
|  | 12 | + | 
|  | 13 | + | 
|  | 14 | +Los dos enlaces de nodo permiten recorrer la lista en cualquier dirección. Si bien agregar o eliminar un nodo en una lista doblemente enlazada requiere cambiar más enlaces que las mismas operaciones en una lista enlazada individualmente, las operaciones son más simples y potencialmente más eficientes (para nodos que no sean los primeros) porque no hay necesidad de realizar un seguimiento de el nodo anterior durante el recorrido o no es necesario recorrer la lista para encontrar el nodo anterior, de modo que se pueda modificar su enlace. | 
|  | 15 | + | 
|  | 16 | +## Pseudocódigo para operaciones básicas | 
|  | 17 | + | 
|  | 18 | +### Insertar | 
|  | 19 | + | 
|  | 20 | +```text | 
|  | 21 | +Add(value) | 
|  | 22 | +  Pre: value is the value to add to the list | 
|  | 23 | +  Post: value has been placed at the tail of the list | 
|  | 24 | +  n ← node(value) | 
|  | 25 | +  if head = ø | 
|  | 26 | +    head ← n | 
|  | 27 | +    tail ← n | 
|  | 28 | +  else | 
|  | 29 | +    n.previous ← tail | 
|  | 30 | +    tail.next ← n | 
|  | 31 | +    tail ← n | 
|  | 32 | +  end if | 
|  | 33 | +end Add | 
|  | 34 | +``` | 
|  | 35 | + | 
|  | 36 | +### Eliminar | 
|  | 37 | + | 
|  | 38 | +```text | 
|  | 39 | +Remove(head, value) | 
|  | 40 | +  Pre: head is the head node in the list | 
|  | 41 | +       value is the value to remove from the list | 
|  | 42 | +  Post: value is removed from the list, true; otherwise false | 
|  | 43 | +  if head = ø | 
|  | 44 | +    return false | 
|  | 45 | +  end if | 
|  | 46 | +  if value = head.value | 
|  | 47 | +    if head = tail | 
|  | 48 | +      head ← ø | 
|  | 49 | +      tail ← ø | 
|  | 50 | +    else | 
|  | 51 | +      head ← head.next | 
|  | 52 | +      head.previous ← ø | 
|  | 53 | +    end if | 
|  | 54 | +    return true | 
|  | 55 | +  end if | 
|  | 56 | +  n ← head.next | 
|  | 57 | +  while n != ø and value !== n.value | 
|  | 58 | +    n ← n.next | 
|  | 59 | +  end while | 
|  | 60 | +  if n = tail | 
|  | 61 | +    tail ← tail.previous | 
|  | 62 | +    tail.next ← ø | 
|  | 63 | +    return true | 
|  | 64 | +  else if n != ø | 
|  | 65 | +    n.previous.next ← n.next | 
|  | 66 | +    n.next.previous ← n.previous | 
|  | 67 | +    return true | 
|  | 68 | +  end if | 
|  | 69 | +  return false | 
|  | 70 | +end Remove | 
|  | 71 | +``` | 
|  | 72 | + | 
|  | 73 | +### Recorrido Inverso | 
|  | 74 | + | 
|  | 75 | +```text | 
|  | 76 | +ReverseTraversal(tail) | 
|  | 77 | +  Pre: tail is the node of the list to traverse | 
|  | 78 | +  Post: the list has been traversed in reverse order | 
|  | 79 | +  n ← tail | 
|  | 80 | +  while n != ø | 
|  | 81 | +    yield n.value | 
|  | 82 | +    n ← n.previous | 
|  | 83 | +  end while | 
|  | 84 | +end Reverse Traversal | 
|  | 85 | +``` | 
|  | 86 | + | 
|  | 87 | +## Complejidades | 
|  | 88 | + | 
|  | 89 | +## Complejidad del Tiempo | 
|  | 90 | + | 
|  | 91 | +| Acceso    | Busqueda    | Inserción | Supresión  | | 
|  | 92 | +| :-------: | :-------: | :-------: | :-------: | | 
|  | 93 | +| O(n)      | O(n)      | O(1)      | O(n)      | | 
|  | 94 | + | 
|  | 95 | +### Complejidad del Espacio | 
|  | 96 | + | 
|  | 97 | +O(n) | 
|  | 98 | + | 
|  | 99 | +## Referencias | 
|  | 100 | + | 
|  | 101 | +- [Wikipedia](https://en.wikipedia.org/wiki/Doubly_linked_list) | 
|  | 102 | +- [YouTube](https://www.youtube.com/watch?v=JdQeNxWCguQ&t=7s&index=72&list=PLLXdhg_r2hKA7DPDsunoDZ-Z769jWn4R8) | 
0 commit comments