def punto1():
    arbol = None
    # 1
    personajes = [
        'Dar Vader', 'Yoda', 'Han Solo', 'Leia Organa', 'C-3PO',
        'Obi-Wan Kenobi', 'Chewbacca', 'R-2D2', 'Luke Skywalker', 'Greedo'
    ]
    pos = 0
    for i in range(len(personajes)):
        dato = [personajes[pos], pos]  # nombre personaje | nrr
        arbol = insertar_nodo(arbol, dato)
        pos += 1

    # 2
    print('Listado ordenado alfabéticamente de manera ascendente')
    inorden(arbol)
    print()

    # 3
    pos = busqueda_arbol_vec(arbol, 'Yod')
    if pos is not None:
        print(pos.info[0], 'se encuentra en la posicion', pos.info[1])
    else:
        print('Yoda NO se encuentra en el arbol')
    print()

    # 4 // el nivel de obi wan kenobi aparece dentro de la funcion por_nivel()
    print('Barrido por nivel')
    por_nivel(arbol)
    print()

    # 5
    x = 'C-3PO'
    arbol, x = eliminar_nodo_vec(arbol, x)
    print('Se eliminó:', x)
    print()
    print('Nuevo arbol sin C-3PO')
    inorden(arbol)
    print()

    # 6
    x = 'Dar Vader'
    arbol, x = eliminar_nodo_vec(arbol, x)
    print('Dar Vader esta mal cargado, modificando...')
    print()
    arbol = insertar_nodo_vec(arbol, ['Darth Vader', 0])
    print('NUEVO ARBOL')
    inorden(arbol)
Example #2
0
arch = abrir('jedis')
for i in range(0, len(arch)):
    print(leer(arch, i))
cerrar(arch)
print()

# b
print('INORDEN POR NOMBRE Y RANKING')
file = abrir('jedis')
inorden_nombrank(arbol_nombre, file)
cerrar(file)
print()

# c
print('BARRIDO RANKING POR NIVEL')
por_nivel(arbol_ranking)
print()
print('BARRIDO ESPECIE POR NIVEL')
por_nivel(arbol_especie)
print()

# d
print('Info de Luke Skywalker')
print('NOMBRE | RANKING | ESPECIE | MAESTRO | COLOR DE SABLE | ORIGEN | AÑO DE NACIMIENTO | ALTURA')
pos = busqueda_arbol(arbol_nombre, 'luke skywalker')
if pos is not None:
    file = abrir('jedis')
    jedi = leer(file, pos.nrr)
    cerrar(file)
    print(jedi)
print()
Example #3
0
for dato in datos:
    x = Personaje(dato[0], dato[1], dato[2])
    guardar(file, x)

# a
# se inserta nombres en arbol
pos = 0
while pos < len(datos):
    personaje = leer(file, pos)
    arbol = insertar_nodo(arbol, personaje.nombre, pos)
    #print(personaje.nombre, 'anadido en la posicion:', pos)
    pos += 1
cerrar(file)

print('Arbol de personajes:')
por_nivel(arbol)
print()

# b
print('1) Alta')
print('2) Baja')
print('3) Modificacion')
print('4) Salir')
control = input('Que desea hacer: ')
print()


def alta_sw(arbol):
    file = abrir('starwars')
    nom = input('Ingrese un nombre: ')
    alt = int(input('Ingrese su altura: '))
Example #4
0
cerrar(file)

# b
busc = input('Busqueda por nombre del pokemon. Ingrese: ')
busqueda_proximidad(arbol_nombre, busc)
print()

# c, d y e
file = abrir('pokemon')
print('Pokemones de tipo: agua, fuego, planta o electrico')
inorden_tipo(arbol_nombre, file)
print()
print('Barrido pokemon por nombre')
inorden_poke_nombre(arbol_nombre, file)
print()
print('Barrido pokemon por numero')
inorden_poke_numero(arbol_numero, file)
print()
print('Barrido pokemon por nivel')
por_nivel(arbol_nombre)
print()
deb = input('Ingrese tipo de debilidad: ')
inorden_debilidad(arbol_nombre, file, deb)
print()
cerrar(file)

#inorden(arbol)
#inorden(arbol_nombre)
#inorden(arbol_numero)
#inorden(arbol_tipo)