https://github.com/mrmorais/tree
Implementação de estruturas de dados em árvores
https://github.com/mrmorais/tree
binary-search-tree heap-tree heapsort tree
Last synced: about 1 month ago
JSON representation
Implementação de estruturas de dados em árvores
- Host: GitHub
- URL: https://github.com/mrmorais/tree
- Owner: mrmorais
- Created: 2017-10-11T12:47:48.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-10-08T11:08:36.000Z (over 7 years ago)
- Last Synced: 2025-01-02T07:26:38.373Z (over 1 year ago)
- Topics: binary-search-tree, heap-tree, heapsort, tree
- Language: C++
- Size: 111 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
### Tree
by Maradona Morais
Implementações em C++ de estruturas de dados organizadas em árvore e seus algoritmos.
#### Features
- Binary Tree & Binary Search Tree
- Parte do código foi reproduzida do livro "Jumping into C++" do [@alexallain](https://twitter.com/alexallain)
- Heap Max
- Heap Min (TO DO)
#### Complexidades
Parte do arquivo [Big-O Cheat Sheet](https://www.packtpub.com/sites/default/files/downloads/4874OS_Appendix_Big_O_Cheat_Sheet.pdf)
**Árvore binária**
| Operação | Melhor caso | Pior caso |
|----------|:----------:|:---------:|
| Buscar | O(log(n)) | O(n) |
| Inserir | O(log(n)) | O(n) |
| Deletar | O(h) | O(n) |
Em que *n* é a quantidade de elementos na árvore e *h* é a altura da mesma. Todos os casos médios foram O(log(n))
**Heap Max**
| Operação | Complexidade |
|----------|:----------:|
| Construir | O(n) |
| Descer | O(log(n)) |
| Deletar | O(log(n)) |
| Subir | O(log(n)) |
| Inserir | O(log(n)) |
| Heap sort | O(nlog(n)) |
Inserção: Insere no final e sobe.
Deleção: Substitui o último com o primeiro e desce o primeiro.
#### Heap sort
```
procedimento heapsort
arranjar(n) // O (n)
m <- n
enquanto (m > 1) faça // O (n)
troca(1, m)
m <- m - 1
descer(1, m) // O(log n)
```