Coder Social home page Coder Social logo

joao-paulo-silva / arvore-binaria-implementacao Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 2.52 MB

Este projeto implementa uma árvore binária para tipos genéricos em linguagem c, o projeto contém estrutura de dados e está organizado no padrão de projeto MVC.

License: MIT License

Makefile 1.37% C 98.63%
arvore-binaria binary-tree estrutura-de-dados linguagem-c exemple exemplo structured-data tad tree-structure

arvore-binaria-implementacao's Introduction

Árvore Binária em linguagem C

Selecione o Idioma / Select the language:

Idioma/language:

  1. Português

  2. English


Documentação do projeto / project documentation:

  1. Docs.

Português

@author João Paulo, Link para executar o projeto no replit.com.

Este projeto implementa uma árvore binária para tipos genéricos, no qual se usa de um tipo address declarado na biblioteca types.h, este tipo equivale a um ponteiro do tipo vazio void *, ou tipo declarado neste arquivo de cabeçalho é o tipo string, no qual é equivalente a char *.


Árvore Binária

Uma árvore binária é uma estrutura de dados caracterizada por: Ou não tem elemento algum. Ou tem um elemento distinto, denominado raiz, com dois ponteiros para duas estruturas diferentes, denominadas subárvore esquerda e subárvore direita. Wikipédia


Decisões para a interface no terminal.

A interface deste projeto utiliza caracteres especiais para a formulação dos menus, também de métodos para o posicionamento no terminal e verificação se as teclas são pressionadas.


Menu Inicial.

Na tela inicial existem dois métodos para sua navegação, sendo elas: as setas do teclado ou os números de 1 a 4, após selecionar uma opção só apertar a tecla enter para entrar na opção.


Inserir Produtos.

Nessa tela é possível a inserção de produtos na árvore podendo inserir 1 ou vários produtos, os produtos não serão inseridos se houver o mesmo código.


Lista Produtos.

Nesta tela pode-se navegar pela árvore usando as setas do teclado para a esquerda e direita, mostrando o botão em cinza claro se não houver filho no nó.


Buscar Produtos.

A opção de buscar produtos abre um novo menu, no qual pode se optar por buscar via nome ou código.


O nó de uma árvore binária caracteriza-se por possuir um o valor que o nó armazena e o endereço para seus filhos (esquerda e direita), como no exemplo abaixo com número inteiro:

// Definição de uma estrutura para ser o tipo nó da árvore.
typedef struct NODE{
  int valor; // Valor armazenado.
  struct NODE * esquerda; // Filho a esquerda.
  struct NODE * direita;  // Filho a esquerda.
}no;

Árvore binária usando o tipo acima:

typedef struct TREE{
  no * raiz;
}Tree;

A implementação é simples, como visto acima, para ajudar na navegação, pode se colocar o nó atual na árvore também para facilitar as operações de navegação na árvore.

typedef struct TREE{
  no * raiz;
  no * atual;
}Tree;

English

@author João Paulo, Link to run the project on replit.com.

This project implements a binary tree for generic types, which uses a type address declared in the types.h library, this type is equivalent to an empty pointer void *, or type declared in this header file is the string type, which is equivalent to char *.


Binary Tree

A binary tree is a data structure characterized by: Either it has no elements. Or it has a distinct element, called the root, with two pointers to two different structures, called the left subtree and right subtree. Wikipédia


Decisions for the interface in the terminal.

The interface of this project uses special characters to formulate the menus, as well as methods for positioning in the terminal and checking if the keys are pressed.


Home Menu.

On the home screen there are two methods for your navigation, namely: the keyboard arrows or the numbers from 1 to 4, after selecting an option just press the enter key to enter the option.


Insert Products.

In this screen it is possible to insert products in the tree, being able to insert 1 or several products, the products will not be inserted if there is the same code.


List Products.

In this screen you can navigate through the tree using the left and right keyboard arrows, showing the button in light gray if there is no child in the node.


Search Products.

The option to search for products opens a new menu, in which you can choose to search by name or code.


Node

The node of a binary tree is characterized by having a value that the node stores and the address for its children (left and right), as in the example below with an integer number:

// Definition of a structure to be the node type of the tree.
typedef struct NODE{
  int valor; // Value stored.
  struct NODE * left; // Child on the left.
  struct NODE * right;  // Child on the right.
}no;

Binary tree using the above type:

typedef struct TREE{
  no * root;
}Tree;

The implementation is simple, as seen above, to help navigation, you can place the current node in the tree as well to facilitate tree navigation operations.

typedef struct TREE{
  no * root;
  no * current;
}Tree;

arvore-binaria-implementacao's People

Contributors

joao-paulo-silva avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

arvore-binaria-implementacao's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.