M1 - Estructura de Datos
M1 - Estructura de Datos
Recursion
2 . 1
Para aprender la recursión, primero hay que aprender la
recursión.
2 . 2
1 function factorial(x)
2 {
3 if (x > -1 && x < 2) return 1; // Cuando -1 < x < 2
4 // devolvemos 1 puesto que 0! = 1 y 1! = 1
5 else if (x < 0) return 0; // Error no existe factorial de números negativos
6 return x * factorial(x - 1); // Si x >= 2 devolvemos el producto de x por el factorial de x - 1
7 }
2 . 3
< Demo />
2 . 4
Estructuras de
Datos - Parte I
3 . 1
Cuando hablamos a estructura de Datos nos referimos a cómo organizamos los datos
cuando programamos. Básicamente, este tema trata de encontrar formar particulares
de organizar datos de tal manera que puedan ser utilizados de manera e ciente.
3 . 2
Arreglos
3 . 3
Sets
3 . 4
Pilas (Stacks)
3 . 5
Pilas (Stacks)
3 . 6
Colas (Queue)
3 . 7
Estructuras de
Datos - Parte II
4 . 1
Listas Enlazadas
1 function Node(data) {
2 this.data = data;
3 this.next = null;
4 }
5
6 function List() {
7 this._length = 0;
8 this.head = null;
9 }
4 . 2
Listas Enlazadas
Al principio de la lista.
En el medio de la lista.
Al nal de la lista.
Sacar un nodo:
4 . 3
Listas Enlazadas
1 List.prototype.add = function(data) {
2 var node = new Node(data),
3 current = this.head;
4 // Si está vacia
5 if (!current) {
6 this.head = node;
7 this._length++;
8 return node;
9 }
10 // Si no esta vacia, recorro hasta encontrar el último
11 while (current.next) {
12 current = current.next;
13 }
14 current.next = node;
15 this._length++;
16 return node;
17 };
18
19 List.prototype.getAll = function(){
20 current = this.head //empezamos en la cabeza
21 if(!current){
22 console.log('La lista esta vacia!')
23 return
24 }
25 while(current){
26 console.log(current.data);
27 current = current.next;
28 }
29 return
30 };
4 . 4
Listas Doblemente Enlazadas
4 . 5
Hash Table
4 . 6
Estructuras de
Datos - Parte III
5 . 1
Árboles (trees)
5 . 2
Árboles (trees)
5 . 3
Tipos de árboles
Binary Tree
5 . 4
Tipos de árboles
AVL Tree
5 . 5
Tipos de árboles
Heap
5 . 6