Skip to content

Commit

Permalink
revisão intro árvores
Browse files Browse the repository at this point in the history
  • Loading branch information
igordsm committed Feb 14, 2024
1 parent 7970c38 commit 3b96169
Show file tree
Hide file tree
Showing 18 changed files with 64 additions and 38 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,20 @@ Este módulo será focado na implementação e aplicação de *Árvores de Busca
## Atividades

- [Introdução e busca](intro/index.md)
- [Inserção](insert/index.md)
<!-- - [Inserção](insert/index.md)
- [Balanceamento](balance/index.md)
- Remoção
- Remoção -->

## Para entregar

- Atividades do módulo no PrairieLearn.

<!--
## Estudo extra
Os seguintes exercícios do LeetCode são interessantes e tem um pouquinho mais de contexto que o usual.
1. [Nós infectados](https://leetcode.com/problems/amount-of-time-for-binary-tree-to-be-infected/)
2. [Valor do nó avô](https://leetcode.com/problems/sum-of-nodes-with-even-valued-grandparent/)
-->
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,27 @@ A busca (*query*) é a operação mais básica de uma ABB e envolve dizer se exi

Já fizemos uma simulação na parte expositiva. Vamos agora praticar antes de implementarmos esse algoritmo nós mesmos.

<ah-diagram>
graph TD
A(15) --- B(5)
A --- C(20)
B --- D(1)
B --- E(10)
E --- H(7)
E --- NULL3( )
C --- NULL2( )
C --- F(25)
F --- NULL1( )
F --- G(30)
</ah-diagram>

{% set graph %}
digraph G {
node [fillcolor="#d9dfff" color="#d9dfff" style="filled"]
15 -> 5
15 -> 20
5 -> 1
5 -> 10
10 -> 7
10 -> null1
20 -> null2
20 -> 25
25 -> null3
25 -> 30
null1 [shape=point]
null2 [shape=point]
null3 [shape=point]
}
{% endset %}
<graphviz-graph graph='{{ graph }}'></graphviz-graph>


!!! exercise long
Busque na árvore acima pelo valor $7$. Escreva abaixo a decisão tomada em cada nó.
Expand Down Expand Up @@ -94,7 +102,7 @@ Antes de prosseguir, volte nos exercícios acima e simule o seu algoritmo.

```c
typedef struct _TreeNode {
struct _TreeNode *left, *right, *parent;
struct _TreeNode *left, *right;
int key;
} TreeNode;
```
Expand All @@ -113,19 +121,25 @@ Vamos começar vendo alguns exemplos de árvores que não são *ABB*.

Para qual nó da árvore abaixo a propriedade básica da ABB não vale?

<ah-diagram>
graph TD
A(15) --- B(14)
A --- C(21)
B --- F(10)
B --- E(16)
C --- G(17)
C --- NULL( )
</ah-diagram>
{% set graph %}
digraph G {
node [fillcolor="#d9dfff" color="#d9dfff" style="filled"]
15 -> 14
15 -> 21
14 -> 10
14 -> 16
21 -> 17
21 -> null1
# sdlfk
null1 [shape=point]
null2 [shape=point]
null3 [shape=point]
}
{% endset %}
<graphviz-graph graph='{{ graph }}'></graphviz-graph>

- [x] 15
- [ ] 14
- [ ] 21
- [ ] 10
- [ ] 16
- [ ] 21
Expand All @@ -134,17 +148,22 @@ Vamos começar vendo alguns exemplos de árvores que não são *ABB*.
!!! exercise choice
Para qual nó da árvore abaixo a propriedade básica da ABB não vale?

<ah-diagram>
graph TD
A(17) --- B(14)
A --- C(22)
B --- F(10)
B --- E(16)
C --- G(21)
C --- NULL( )
G --- A2(18)
G --- A3(23)
</ah-diagram>
{% set graph %}
digraph G {
node [fillcolor="#d9dfff" color="#d9dfff" style="filled"]
17 -> 14
17 -> 22
14 -> 10
14 -> 16
22 -> 21
22 -> null1
21 -> 18
21 -> 23
# sdlfk
null1 [shape=point]
}
{% endset %}
<graphviz-graph graph='{{ graph }}'></graphviz-graph>

- [ ] 17
- [ ] 14
Expand All @@ -166,7 +185,7 @@ Esses dois passos tem algo em comum: eles envolvem visitar todos os nós da árv
Escreva abaixo um rascunho de um algoritmo para visitar todos os nós de uma árvore.

!!! answer
Será discutido em **02/10**.
Será discutido na próxima aula.

Com base nesse algoritmo, faça a implementação no PrairieLearn do algoritmo para checar se uma árvore é válida.

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
2 changes: 2 additions & 0 deletions content/js/external.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ import("https://cdn.jsdelivr.net/gh/active-handout/web-components@main/src/ah-te
import("https://cdn.jsdelivr.net/gh/active-handout/web-components@main/src/ah-button.mjs");
import("https://cdn.jsdelivr.net/gh/active-handout/web-components@main/src/ah-diagram.mjs");
import("https://cdn.jsdelivr.net/gh/active-handout/web-components@main/src/ah-external-content.mjs");

import("https://unpkg.com/[email protected]/dist/graph-bundled.min.js");
2 changes: 2 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ nav:
- "Alocação de memória": 0-linguagem-C/malloc.md
- "ADT em C": 0-linguagem-C/adt-c.md
- "Debug": 0-linguagem-C/debug.md
- "1 - Árvores (iteração e inserção)":
- "Índice": 1-arvores-intro/index.md
#- "1 - Grafos e Componentes":
# - "Índice": 1-grafos-componentes/index.md
# - "Introdução": 1-grafos-componentes/intro.md
Expand Down

0 comments on commit 3b96169

Please sign in to comment.