Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include "arvore.h"
- t_no* aloca_no(int valor){
- t_no* ptr = (t_no *) malloc(sizeof(t_no));
- ptr->dado = valor;
- ptr->direita = NULL;
- ptr->esquerda = NULL;
- return ptr;
- }
- t_tree* first(){
- t_tree* ptr = (t_tree *) malloc(sizeof(t_tree));
- ptr->inicio = NULL;
- return ptr;
- }
- int type(){
- int num;
- printf("Informe o tipo de busca da arvore binaria: ");
- printf("1- pre-ordem\n");
- printf("2- em ordem\n");
- printf("3- pos-ordem\n");
- scanf("%d", &num);
- return num;
- }
- void insere(t_no* node, t_tree* raiz){
- int value, check_raiz = 1;
- while(check_raiz == 1/*Ajustar essa condicao*/){
- if(raiz->inicio == NULL){
- printf("Valor do começo: ");
- scanf("%d", &value);
- node = aloca_no(value);
- raiz->inicio = node;
- insere(node, raiz);
- }
- else{
- if(node->esquerda == NULL){
- printf("Valor do no: ");
- scanf("%d", &value);
- node->esquerda = aloca_no(value);
- insere(node, raiz);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement