From fd218bede0dc68fee9732a2b7fa09cfa868a7ca1 Mon Sep 17 00:00:00 2001 From: Abreu Date: Wed, 22 Sep 2021 11:24:42 -0300 Subject: [PATCH] Added abstracts --- .gitignore | 1 - .../Semana 04/Semana 04.md | 2 - .../Semana 04/doubly_linked_list.c | 10 +- .../Semana 05/Semana 05.md | 38 +++++++ .../Semana 05/circular_list.c | 107 ++++++++++++++++++ .../Semana 05/stack.c | 48 ++++++++ BxComp | 1 + .../04 - Dependência linear.md | 91 +++++++++++++++ ... um espaço vetorial finitamente gerado.md | 14 +++ .../06 - Dimensão.md | 33 ++++++ 10 files changed, 334 insertions(+), 11 deletions(-) create mode 100644 Algoritmos e Estruturas de Dados I/Semana 05/Semana 05.md create mode 100644 Algoritmos e Estruturas de Dados I/Semana 05/circular_list.c create mode 100644 Algoritmos e Estruturas de Dados I/Semana 05/stack.c create mode 160000 BxComp create mode 100644 Matrizes, Vetores e Geometria Analítica/05 - Base de um espaço vetorial finitamente gerado.md create mode 100644 Matrizes, Vetores e Geometria Analítica/06 - Dimensão.md diff --git a/.gitignore b/.gitignore index 3b4f2c6..0156aed 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ *.out *.pdf -BxComp/ diff --git a/Algoritmos e Estruturas de Dados I/Semana 04/Semana 04.md b/Algoritmos e Estruturas de Dados I/Semana 04/Semana 04.md index 8431ab0..4ac622e 100644 --- a/Algoritmos e Estruturas de Dados I/Semana 04/Semana 04.md +++ b/Algoritmos e Estruturas de Dados I/Semana 04/Semana 04.md @@ -2,8 +2,6 @@ > Por Guilherme de Abreu Barreto, nUSP: 12543033. - - ```c #include #include diff --git a/Algoritmos e Estruturas de Dados I/Semana 04/doubly_linked_list.c b/Algoritmos e Estruturas de Dados I/Semana 04/doubly_linked_list.c index 20e5e03..15e62d4 100644 --- a/Algoritmos e Estruturas de Dados I/Semana 04/doubly_linked_list.c +++ b/Algoritmos e Estruturas de Dados I/Semana 04/doubly_linked_list.c @@ -18,20 +18,14 @@ void insertIn (List *l, int value) { if (l->start != NULL) { if (abs(value - l->start->value) < abs(value - l->end->value)) { - next = l->start; - while (next != NULL && next->value < value) { + for (next = l->start; next != NULL && next->value < value; next = next->next) prev = next; - next = next->next; - } if (next != NULL && next->value == value) return; } else { - prev = l->end; - while (prev != NULL && prev->value > value) { + for (prev = l->end; prev != NULL && prev->value > value; prev = prev->prev) next = prev; - prev = prev->prev; - } if (prev != NULL && prev->value == value) return; } diff --git a/Algoritmos e Estruturas de Dados I/Semana 05/Semana 05.md b/Algoritmos e Estruturas de Dados I/Semana 05/Semana 05.md new file mode 100644 index 0000000..1bcbb87 --- /dev/null +++ b/Algoritmos e Estruturas de Dados I/Semana 05/Semana 05.md @@ -0,0 +1,38 @@ +# Semana 04: resposta ao [exercício proposto](http://www.each.usp.br/digiampietri/ACH2023/ACH2023_AtividadeSemanal05.pdf) + +> Por Guilherme de Abreu Barreto[^1] + +Para uma estrutura de tipo `stack` definida como: + +```c +typedef struct { + int * value, size, top; +} Stack; +``` + +E inicializada na forma: + +```c +Stack * initialize (int size) { + Stack *s = malloc(sizeof(*s)); + s->value = malloc(size * sizeof(s->value)); + s->size = size; + s->top = -1; + return s; +} +``` + +Tem-se impressos os conteúdos nesta armazenados, na ordem do fundo até o topo, por intermédio da seguinte função: + +```c +void reversePrintStack (Stack *s) { + int i; + + printf("Pilha (da base para o topo): \" "); + for (i = 0; i <= s->top; i++) + printf("%d\n", s->value[i]); + printf("\"\n"); +} +``` + +[^1]: nUSP: 12543033 \ No newline at end of file diff --git a/Algoritmos e Estruturas de Dados I/Semana 05/circular_list.c b/Algoritmos e Estruturas de Dados I/Semana 05/circular_list.c new file mode 100644 index 0000000..de49d48 --- /dev/null +++ b/Algoritmos e Estruturas de Dados I/Semana 05/circular_list.c @@ -0,0 +1,107 @@ +#include +#include +#include + +typedef struct node { + int value; + struct node *prev; + struct node *next; +} Node; + +Node * initialize () { + Node *n = malloc(sizeof(*n)); + n->prev = n->next = n; + return n; +} + +void reinitilize (Node * HEAD) { + Node *current = HEAD->next; + + while (current != HEAD) { + current = current->next; + free(current->prev); + } + current->next = current->prev = current; +} + +int listSize (Node *HEAD) { + Node *current = HEAD->next; + int size; + + for (size = 0; current != HEAD; size++) + current = current->next; + return size; +} + +void printList (Node *HEAD) { + Node *current = HEAD->next; + + printf("Lista: \""); + while (current != HEAD) { + printf("%d ", current->value); + current = current->next; + } + printf("\"\n"); +} + +Node * findIn(Node *HEAD, int value) { + Node *current = HEAD->next; + HEAD->value = value; + + while (current->value != value) + current = current->next; + return (current != HEAD) ? current : NULL; +} + +/* Implementação que considera uma lista ordenada */ +Node * findInOrdered(Node *HEAD, int value) { + Node *current; + + if (abs(value - HEAD->next->value) < abs(value - HEAD->prev->value)) { + current = HEAD->next; + while (current->value < value) + current = current->next; + } + else { + current = HEAD->prev; + while (current-> value > value) + current = current->prev; + } + return (current == HEAD || current->value != value) ? NULL : current; +} + +bool insertIn(Node *HEAD, int value) { + Node *prev, *current, *next; + prev = next = HEAD; + + if (abs(value - HEAD->next->value) < abs(value - HEAD->prev->value)) { + for (next = HEAD->next; next->next != HEAD && next->value < value; next = next->next) + prev = next; + if (next->value == value) + return false; + } + else { + for (prev = HEAD->prev; prev->prev != HEAD && prev->value > value; prev = prev->prev) + next = prev; + if (prev->value == value) + return false; + } + + current = malloc(sizeof(*current)); + current->value = value; + current->next = prev->next; + prev->next = current; + current->prev = next->prev; + next->prev = current; + return true; +} + +bool removeFrom(Node *HEAD, int value) { + Node * current = findInOrdered(HEAD, value); + if (current == NULL) + return false; + current->next->prev = current->prev; + current->prev->next = current->next; + free(current); + return true; +} diff --git a/Algoritmos e Estruturas de Dados I/Semana 05/stack.c b/Algoritmos e Estruturas de Dados I/Semana 05/stack.c new file mode 100644 index 0000000..74a2dfe --- /dev/null +++ b/Algoritmos e Estruturas de Dados I/Semana 05/stack.c @@ -0,0 +1,48 @@ +#include +#include +#include + +typedef struct { + int * value, size, top; +} Stack; + +Stack * initialize (int size) { + Stack *s = malloc(sizeof(*s)); + s->value = malloc(size * sizeof(s->value)); + s->size = size; + s->top = -1; + return s; +} + +void printStack (Stack *s) { + int i; + + printf("Lista: \""); + for (i = s->top; i >= 0; i--) + printf("%d ", s->value[i]); + printf("\"\n"); +} + +void reversePrintStack (Stack *s) { + int i; + + printf("Pilha (da base para o topo): \" "); + for (i = 0; i <= s->top; i++) + printf("%d\n", s->value[i]); + printf("\"\n"); +} + +bool push (Stack * s, int value) { + if (s->top >= s->size + 1) + return false; + s->top = s->top + 1; + s->value[s->top] = value; + return true; +} + +int pop (Stack * s) { + if (s->top < 0) + return EOF; + s->top -= 1; + return s->value[s->top + 1]; +} diff --git a/BxComp b/BxComp new file mode 160000 index 0000000..c1df340 --- /dev/null +++ b/BxComp @@ -0,0 +1 @@ +Subproject commit c1df3404964c1ab41cfad7618e7ef8d7b1e85668 diff --git a/Matrizes, Vetores e Geometria Analítica/04 - Dependência linear.md b/Matrizes, Vetores e Geometria Analítica/04 - Dependência linear.md index baab870..029cd95 100644 --- a/Matrizes, Vetores e Geometria Analítica/04 - Dependência linear.md +++ b/Matrizes, Vetores e Geometria Analítica/04 - Dependência linear.md @@ -2,4 +2,95 @@ Seja $V$ um espaço vetorial sobre $\R$. +## Conjunto linearmente independente (L.I.) +Dizemos que um conjunto $L = \{u_1, \dots, u_2\} \subset V$ é *linearmente independente* se e somente se, uma igualdade do tipo + +$$ +a_1u_1 + \dots + a_nu_n = e +$$ + +onde $a \in \R$, for possível **somente** quando $a_1 = \dots = a_n = 0$. Outro caso possível é quando o conjunto $L$ em questão é nulo ($L = \{\empty\}$). + +## Conjunto linearmente dependente (L.D.) + +Quando o conjunto não é nulo e a somatória anteriormente descrita só é possível se $\exists\ a \not = 0$. + +## Propriedades da dependência linear + +**P1.** Se um conjunto $L \subset V$ contém o vetor nulo, então esse conjunto é L. D. + +Demonstração: Seja $S = \{e, u_2, \dots, u_n\}$, então + +$$ +ae + 0u_2 + \dots + 0u_n = e +$$ + +para todo $a \not = 0$. Isso é suficiente para concluir que S é L. D.[^1] $\blacksquare$ + +**P2.** Se $L = {u}$, onde $L \subset V$ e $u \not = e$, então $L$ é L.I. + +Demonstração: Se $au = e$, e $u \not = e$, então $a = 0$. $\blacksquare$ + +**P3.** Se $S = \{u_1, \dots, u_n\} \subset V$ é L.D., então um dos seus vetores é a combinação linear de todos os demais. + +Demonstração: por hipótese existem números reais $a_1, \dots, a_n$ onde pelo menos um é igual a zero. Venhamos a estabelecer que $a_1 \not = 0$ então o inverso de $a_1$, ($a_1^{-1}$) existe e: + +$a_1u_1 + a_2u_2 + \dots a_nu_n = e \implies +u_1 = - \dfrac{a_2u_2 + \dots + a_nu_n }{a_1} = \\ a_1^{-1}a_2u_2 + \dots + a_1^{-1}a_nu_n +$ + +O que mostra que $u_1$ equivale à combinação linear de $u_2, \dots, u_n$: + +$$ +u_1 = [S] = \{a_1^{-1}a_2u_2 + \dots + a_1^{-1}a_nu_n \mid a_1, \dots, a_n \in \R\} \blacksquare +$$ + +**P4.** Se $S_1$ e $S_2$ são subconjuntos finitos e não vazios de V, se $S_1 \subset S_2$ e $S_1$ é L.D., então $S_2$ também é L.D. + +Demonstração: como nem todos os escalares que figuram em $S_1$ são nulos, o que configura L.D., e $S_2$ contém $S_1$, então o conjunto dos escalares em $S_2$ também não é inteiramente nulo. $\blacksquare$ + +**P5.** Se $S_1$ e $S_2$ são subconjuntos finitos e não vazios de V, se $S_1 \subset S_2$ e $S_2$ é L.I., então $S_2$ também é L.I. + +Demonstração: situação complementar à aquele da propriedade anterior. $\blacksquare$ + +**P6.** Se $S = \{u_1, \dots, u_n\} \subset V$ é L.I, e para um certo $u \in V$ tem-se $S \cup \{u\} = \{u_1, \dots, u_n, u\}$ L.D., então o vetor $u$ é combinação linear dos vetores $u_1, \dots, u_n$, isto é, $u \in [S]$. + +Demonstração: Por hipótese tem-se uma igualdade + +$$ +a_1u_1 + \dots + a_nu_n + au = e +$$ + +onde nem todos os escalares que figuram nela são nulos. Afirmamos que um dos escalares não nulos é o $a$. De fato, se $a = 0$, então + +$$ +a_1u_1 + \dots a_nu_n = e +$$ + +Como porém o conjunto S é L.I., esta última igualdade só seria possível com $a_1 = \dots = a_n$. Daí, se $a = 0$, então $a = a_1 = \dots = a_n = 0$, o que contradiz a hipótese. + +Já que $a \not = 0$, temos que: + +$ +a_1u_1 + \dots a_nu_n + au = e\\\ \\ +\implies u = - \dfrac{a_1u_1 + \dots + a_nu_n}{a}= (a_1a^{-1})u_1 + \dots + (a_na^{-1})u_n +$ + +**P7.** Se $S = \{u_1, \dots, u_j, \dots, u_n\}$ e $u_j \in [S - {u_j}]$ (isto é, $u_j$ é combinação linear doutros vetores contidos em S), então + +$$ +[S] = [S - \{u_j\}] +$$ + +Demonstração: Faremos a prova supondo $j = 1$, o que nada tira em generalidade. É obvio que $[S - \{u_1\}] \subset [S]$, pois $S - {u_1} \subset S$. Como foi dito que $u_j$ é a combinação linear dos demais vetores, aplicando a propriedade **P3**, temos: + +$$ +u_1 = - \dfrac{a_2u_2 + \dots + a_nu_n}{a_1} = b_2u_2 + \dots + b_nu_n = [S] +$$ + +Onde $b_i = -a_1^{-1}a_i$. Continuando, + +$$ +b_2u_2 + \dots + b_nu_n = [S - \{u_1\}] \therefore [S - \{u_1\}] = [S] +$$ \ No newline at end of file diff --git a/Matrizes, Vetores e Geometria Analítica/05 - Base de um espaço vetorial finitamente gerado.md b/Matrizes, Vetores e Geometria Analítica/05 - Base de um espaço vetorial finitamente gerado.md new file mode 100644 index 0000000..cb80761 --- /dev/null +++ b/Matrizes, Vetores e Geometria Analítica/05 - Base de um espaço vetorial finitamente gerado.md @@ -0,0 +1,14 @@ +# Base de um espaço vetorial finitamente gerado + +Seja $V$ um espaço vetorial finitamente gerado. Uma base de $V$ é o subconjunto finito $B \subset V$ para o qual as seguintes condições se verificam: + +1. $[B] = V$; + +2. $B$ é L.I. + +Por exemplo, + +- $\{(1,0), (0,1)\}$ é uma base do $\R^2$ +- $\{(1, 0, \dots, 0), (0,1,0, \dots, 0), \dots, (0, \dots, 0, 1)\}$ é uma base do $\R^n$ + +Fica convencionado que se $V = \{e\}$, seu subconjunto gerador é o conjunto vazio: $[\empty] = V$. \ No newline at end of file diff --git a/Matrizes, Vetores e Geometria Analítica/06 - Dimensão.md b/Matrizes, Vetores e Geometria Analítica/06 - Dimensão.md new file mode 100644 index 0000000..5588e3e --- /dev/null +++ b/Matrizes, Vetores e Geometria Analítica/06 - Dimensão.md @@ -0,0 +1,33 @@ +# Dimensão + +Sendo V um espaço vetorial finitamente gerado. + +## Proposição 1: Teorema da invariância + +Para quaisquer bases $B$ que $V$ possa vir a ter, estas possuem um mesmo número de vetores. Esta quantidade invariável de vetores denomina-se a *dimensão* (finita) de $V$ (notação: $\dim V$). + +Decorre da definição que: + +- $\dim \R^2 = 2$ + +- $\dim \R^n = n$ + +- $\dim M_{m \times n}(\R) = m \cdot n$ + +- $\dim P_n(\R) = n + 1$ + +- $\dim {e} = 0$ + +## Proposição 2: Teorema do completamento + +Seja a dimensão de $V$ um valor $n \ge 1$, e $S$ um subconjunto de $V$ contendo $r < n$ vetores $u$. Então existem $n - r$ vetores em $V$ que necessitam ser acrescidos à $S$ para que este subconjunto possa descrever uma base $B = \{u_1, \dots, u_r, \dots, u_n\}$ de $V$. + +## Proposição 3 + +Todo sub-espaço vetorial de um espaço finitamente gerado também é finitamente gerado. + +### Proposição 4 + +Seja $W$ um sub-espaço vetorial de $V$. Se $\dim W = \dim V$, então $W = V$. + +