I am trying to create a b* tree data structure using list.
List<list<node>>
List<list<object>>
I am not pretty sure, in the first one I just get 2 levels of the tree, but in the case, the tree will be deeper? I think in the second case fit more with my needs because I can use a list as an object. I read in a forum the usage of a dictionary is better for the tree structure. But I am not sure if I can create a dictionary of a dictionary.
List<<List<<object>> listas;
Dictionary<int, Dictionary<int, Object>> dicionario;
I am new in the data structure topics and collection generics library. Which one is more functionally and easy to use list or dictionaries? by the way, my native language is not English please, don't be rude.
If you have different ideas please feel free to provide them to me
What I have tried:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ArbolB
{
public class pagina
{
private int nodo;
private List<List<int>> elementos;
private List<List<Object>> listas;
Dictionary<int, Dictionary<int, Object>> dicionario;
private List<int> inicial;
private List<int> final;
public int Nodo
{
get;
set;
}
public List<List<int>> Elementos
{
set
{
elementos = new List<List<int>>();
}
get
{
return elementos;
}
}
public pagina()
{
}
public pagina(int numero)
{
CrearRaiz(numero);
}
public void AgregarElmento(int numero)
{
if(Elementos == null)
{
CrearRaiz(numero);
}
else
{
Elementos[0].Add(numero);
}
}
private void CrearRaiz(int numero)
{
List<int> raiz = new List<int>();
raiz.Add(numero);
Elementos = Elementos;
Elementos.Add(raiz);
}
}
}