10 The Most Used Data Structures
10 The Most Used Data Structures
Lesson Transcript 03
Transcript + Translation 09
Vocabulary 23
Grammar 29
Mistakes 40
Today we’re gonna be discussing Data Structures. Now, what exactly are Data
Structures? Well, a data structure is technically a named location that could be used
to store organized data.
We’re gonna be talking about a lot of different types of Data Structures, from
most basic to more advanced types. You’re gonna come across a lot of different types
of Data Structures, and it’s good to be well versed in just about every type of form you
could see, especially the basic ones.
We’ll be discussing the first data structure, called a “stack”. Now, this is one of
the most commonly referred to and known data structure. It is a linear data
structure that follows the principle of “Last In, and First Out”, this means that the last
elements inserted inside a stack is removed first.
You could think of the “stack” Data Structure as a pile of plates, all on top of
one another. Though simple, stacks are incredibly powerful, and they’re most
commonly used in compilers, and even in memory caches, where URLs can be saved
when you’re jumping between different hyperlinks.
Now, talking about stacks, we also… also need to know about “queues”. A queue is a
data structure that follows the same kind of linear format, but instead of using “Last In,
First Out”, it uses the “First In, First Out” methodology. Essentially, the first one in (in,
say, a line, here) is gonna be, then, the first one out when the next one comes in.
3
Lesson Transcript The Most Used Data Structures
Think of a line for a hot dog stand. You will have customers waiting as you serve
others. The people waiting are in a queue per se, and queuing data structures can be
used in this application, where you can try to find optimal serving times. Moreover,
you could even use it for CPU scaling applications and, again, ticket services, such as
movie theaters.
Moving on to another data structure... is “lists”, and everyone is pretty familiar with
lists, but in this instance, Data Structures, when it comes to lists, there are several
categories of lists. A Linked List is a linear data structure that includes a series of
connected nodes. Here, each node stores the data and address of the next node
linked to it.
Linked Lists can be of multiple types: they can be singly linked lists, doubly, and
circular linked lists, and lists are very common in today’s programming languages,
such as Python, which even utilizes dictionaries, and Java, C, C+.
But the last data structure I’d like to discuss, and more in basic, relative terms, is a hash
table. Hash tables take a new index by processing it using keys. The element
corresponding to that key is stored in the overall index.
Essentially, hash tables are Data Structures that store elements in a “key-value”
pair. You could think of this as, like, a “row to column”, or a “observation to variable”
kind of pairing, where the key is a unique integer that is used to store for indexing
the value, and the value is the data.
4
Lesson Transcript The Most Used Data Structures
In hash tables, you’re gonna be having to deal with hash functions, and these
hash functions sometimes may generate multiple keys for, say, the same index, and
this will be a conflicts within your hash table. This is called a “hash collision”, it’s
very common, and there’s a lot of methodologies to go about trying to solve this.
One of them is called “chaining”, it’s a hash function that produces the same
index by using multiple elements, and these elements are stored in the same
index by using a doubly linked list. So, instead of having one node, there’s two.
Now, let’s discuss a more advanced type of Data Structure, which is “trees”, decision
trees. These previous data structures that we were just talking about: lists,
stacks, queues, hash tables, they’re all examples of linear data structures that
store data sequentially. But in order to perform any operation in a linear data
structure, the time complexity increases with the increase in the data size.
In today’s modern time, this can be very computationally taxing, but different tree
Data Structures allow quicker and easier access to the data, as if it was non-
linear. Now, a decision tree is composed entirely out of nodes and edges. A node
is an entity that contains a key or value and points to child nodes, nodes underneath
it. So, the top node is usually referred to as the “root node”, the topmost, and
beneath it are gonna be child nodes.
5
Lesson Transcript The Most Used Data Structures
Now, what connects these nodes is something called an “edge”. Edges can connect
any two nodes, and overall, nodes are commonly referred to as “child nodes”, but
also “internal” or “external” nodes, where the external node is the last and final node
at the end of the tree, of the path; and internal nodes are the ones that connect
to at least one child, one or more.
Now, decision trees, again, have a lot of capabilities and a lot of different types of
structures within them. There’s a lot of different types. One very, very common,
and always referred to, and I’ve used it so many times at this point in my career,
is a binary tree. Binary tree is a data structure in which each parent node can have
two children.
Each node of a binary tree consists of three items: a data item, address to the left
child, and then, address to the right child. Essentially, a node, and then, two child nodes,
left and right. Of course, there are gonna be different types of tree setups that are
binary, because we can have multiple combinations of different parent nodes to
one another.
One commonly referred to binary tree type is a “full binary tree”, which is a
special type of binary tree, in which every parent node or internal node has either
two or no children. There’s also a “perfect binary tree”, in which every internal node
has exactly two children nodes, and all the leaf nodes, otherwise known as external
nodes, are at the same level, they’re parallel.
6
Lesson Transcript The Most Used Data Structures
Now, what does this mean, “level”? When you start with your root, and you start breaking
down the tree, and you start linking more and more, down to more nodes further on,
you’ll notice that, as we go down, you kind of make a pyramid. You could refer to
these different hierarchies as “levels”.
So, again, a “perfect binary tree” is... every internal node has exactly two children and
they’re all on the same level. There’s not one leaf or… I’m sorry… one external node on
the bottom of, say, a three-level decision tree, there’s not a fourth level where one
node sits by itself.
And then, there’s a “complete binary tree”, which is like a “full binary tree” with two
major differences: every level must be completely filled; and all the leaf elements
(external nodes) must lean towards the left.
Lastly, we should discuss what kind of operations we can do in binary trees, because
we can do a few things when it comes to decision trees. Typical and most common
operations include insertion and deletion, which sound pretty self-explanatory.
Essentially, insertion is nodes that can be inserted into the binary tree between two
other nodes or added after a leaf node (again, that external node, the last one); and
deletion is, again, the process whereby a node is removed from the tree, and
only certain nodes in a binary tree can be removed unambiguously.
7
Lesson Transcript The Most Used Data Structures
B-trees generalize the binary search tree, allowing for nodes with more than
just two children. Unlike other self-balancing binary trees, the B-tree is well
suited for storage systems that read and write relatively large blocks of data, and you’ll
see B-trees commonly used in data systems, databases, data managing software,
and even in filing systems.
What makes B-trees more useful and even gives them an advantage over other types
of tree methodologies and Data Structures, (is) that B-trees and databases keep
keys in a sorted order for sequential traversing; it also uses a hierarchical
index to minimize the number of disk reads; and it keeps the index balanced with a
recursive algorithm, meaning, it constantly goes back through itself to the beginning
and reiterates this every time.
You could see now the advantages of how these B-trees can be, again, a little complex,
but yet so efficient and reliable in terms of data storage and data management.
8
Transcript + Translation The Most Used Data Structures
English Português
Today we’re gonna be discussing Data Hoje nós vamos discutir Estruturas de
Structures. Now, what exactly are Data Dados. Agora, o que exatamente são
Structures? Well, a data structure is Estruturas de Dados? Bem, uma estrutura
technically a named location that could be de dados é tecnicamente uma localização
used to store organized data. nomeada que pode ser usada para
armazenar dados organizados.
We’re gonna be talking about a lot Nós vamos falar sobre muitos tipos
from most basic to more advanced tipos mais básicos até mais avançados.
types. You’re gonna come across a lot Você vai encontrar muitos tipos diferentes
and it’s good to be well versed in just versado em basicamente todos os tipos de
about every type of form you could see, forma que você possa ver, especialmente
9
Transcript + Translation The Most Used Data Structures
English Português
We’ll be discussing the first data Nós vamos discutir a primeira estrutura
structure, called a “stack”. Now, this is de dados, chamada de uma “pilha”. Agora,
one of the most commonly referred to essa é uma das estruturas de dados mais
and known data structure. It is a linear comumente referidas e conhecidas. É
data structure that follows the principle uma estrutura de dados linear que segue
of “Last In, and First Out”, this means that o princípio de “Último a entrar, e Primeiro
the last elements inserted inside a a Sair”, isso significa que o último elemento
stack is removed first. inserido dentro de uma pilha é removido
primeiro.
You could think of the “stack” Data Você poderia pensar na Estrutura de
Structure as a pile of plates, all on top Dados “pilha” como uma pilha de pratos,
of one another. Though simple, stacks todos uns em cima dos outros. Embora
are incredibly powerful, and they’re simples, as pilhas são incrivelmente
most commonly used in compilers, and poderosas, e elas são mais comumente
even in memory caches, where URLs can usadas em compiladores, e até mesmo em
be saved when you’re jumping between caches de memória, onde URLs podem
different hyperlinks. ser salvas quando você está pulando
entre diferentes hiperlinks.
10
Transcript + Translation The Most Used Data Structures
English Português
Now, talking about stacks, we also… also Agora, falando sobre pilhas, nós também...
need to know about “queues”. A queue também precisamos saber sobre “filas”.
is a data structure that follows the same Uma fila é uma estrutura de dados que
kind of linear format, but instead of using segue o mesmo tipo de formato linear, mas
“Last In, First Out”, it uses the “First In, em vez de usar “Último a Entrar, Primeiro
First Out” methodology. Essentially, the a Sair”, usa a metodologia “Primeiro a
first one in (in, say, a line, here) is gonna Entrar, Primeiro a Sair”. Essencialmente, o
be, then, the first one out when the next primeiro a entrar (em, digamos, uma fila,
one comes in. aqui) será, daí, o primeiro a sair quando o
próximo entrar.
Think of a line for a hot dog stand. You Pense em uma fila para uma barraca de
will have customers waiting as you cachorro-quente. Você vai ter clientes
serve others. The people waiting are esperando enquanto você atende os outros.
in a queue per se, and queuing data As pessoas esperando estão em uma fila
structures can be used in this application, per se, e estruturas de dados de filas podem
where you can try to find optimal serving ser usadas nessa aplicação, onde você pode
times. Moreover, you could even use it tentar encontrar os tempos de atendimento
for CPU scaling applications and, again, ideais. Além disso, você pode até mesmo
ticket services, such as movie theaters. usá-la para aplicações de dimensionamento
de CPU e, novamente, serviços de ingressos,
como cinemas.
11
Transcript + Translation The Most Used Data Structures
English Português
Linked Lists can be of multiple types: Listas Ligadas podem ser de vários
they can be singly linked lists, doubly, tipos: elas podem ser listas ligadas
and circular linked lists, and lists are individualmente, duplamente e listas
very common in today’s programming ligadas circulares, e listas são muito
languages, such as Python, which even comuns nas linguagens de programação
utilizes dictionaries, and Java, C, C+. de hoje, como Python, que até utiliza
dicionários, e Java, C, C+.
12
Transcript + Translation The Most Used Data Structures
English Português
But the last data structure I’d like to Mas a última estrutura de dados que eu
discuss, and more in basic, relative terms, gostaria de discutir, e mais em termos
is a hash table. Hash tables take a básicos, relativos, é uma tabela hash.
new index by processing it using keys. Tabelas hash pegam um novo índice
The element corresponding to that key is processando-o usando chaves. O
stored in the overall index. elemento correspondente a essa chave é
armazenado no índice geral.
13
Transcript + Translation The Most Used Data Structures
English Português
In hash tables, you’re gonna be Em tabelas hash, você vai ter que lidar
having to deal with hash functions, com funções hash, e essas funções hash
and these hash functions sometimes às vezes podem gerar múltiplas chaves
may generate multiple keys for, say, the para, digamos, o mesmo índice, e isso vai
same index, and this will be a conflicts ser um conflito dentro da sua tabela hash.
within your hash table. This is called Isso é chamado de “colisão hash”, é muito
a “hash collision”, it’s very common, and comum, e existem muitas metodologias
there’s a lot of methodologies to go para proceder em tentar resolver isso.
about trying to solve this.
14
Transcript + Translation The Most Used Data Structures
English Português
Now, let’s discuss a more advanced type of Agora, vamos discutir um tipo mais
Data Structure, which is “trees”, decision avançado de Estrutura de Dados, que
trees. These previous data structures são “árvores”, árvores de decisão. Essas
that we were just talking about: lists, estruturas de dados anteriores sobre as
stacks, queues, hash tables, they’re all quais nós estávamos falando há pouco:
examples of linear data structures that listas, pilhas, filas, tabelas hash, elas
store data sequentially. But in order são todas exemplos de estruturas de
to perform any operation in a linear dados lineares que armazenam dados
data structure, the time complexity sequencialmente. Mas para realizar
increases with the increase in the data qualquer operação em uma estrutura de
size. dados linear, a complexidade de tempo
aumenta com o aumento no tamanho
dos dados.
15
Transcript + Translation The Most Used Data Structures
English Português
In today’s modern time, this can be very Nos tempos modernos de hoje, isso
computationally taxing, but different pode ser muito desgastante em
tree Data Structures allow quicker termos computacionais, mas diferentes
and easier access to the data, as if it Estruturas de Dados de árvore permitem
was non-linear. Now, a decision tree is um acesso mais rápido e mais fácil aos
composed entirely out of nodes and dados, como se eles fossem não lineares.
edges. A node is an entity that contains Agora, uma árvore de decisão é composta
a key or value and points to child nodes, inteiramente de nós e arestas. Um nó é
nodes underneath it. So, the top node is uma entidade que contém uma chave ou
usually referred to as the “root node”, valor e aponta para nós filhos, nós abaixo
the topmost, and beneath it are gonna dele. Então, o nó superior é geralmente
be child nodes. referido como o “nó raiz”, o mais alto, e
abaixo dele vão estar nós filhos.
Now, what connects these nodes is Agora, o que conecta esses nós é algo
something called an “edge”. Edges can chamado de uma “aresta”. Arestas podem
connect any two nodes, and overall, conectar quaisquer dois nós, e no geral,
nodes are commonly referred to as os nós são comumente referidos como
“child nodes”, but also “internal” or “nós filhos”, mas também nós “internos”
“external” nodes, where the external ou “externos”, onde o nó externo é o
node is the last and final node at the último e derradeiro nó no final da árvore,
end of the tree, of the path; and internal do caminho; e nós internos são aqueles
nodes are the ones that connect to at que se conectam a pelo menos um filho,
least one child, one or more. um ou mais.
16
Transcript + Translation The Most Used Data Structures
English Português
Now, decision trees, again, have a lot Agora, árvores de decisão, novamente,
of capabilities and a lot of different types têm muitos recursos e muitos tipos
of structures within them. There’s a lot diferentes de estruturas dentro delas,
of different types. One very, very existem muitos tipos diferentes. Um que
common, and always referred to, and é muito, muito comum, e sempre referido,
I’ve used it so many times at this e eu o usei tantas vezes neste ponto na
point in my career, is a binary tree. minha carreira, é uma árvore binária. A
Binary tree is a data structure in which árvore binária é uma estrutura de dados
each parent node can have two children. na qual cada nó pai pode ter dois filhos.
Each node of a binary tree consists of Cada nó de uma árvore binária consiste em
three items: a data item, address to the três itens: um item de dados, endereço para
left child, and then, address to the right o filho esquerdo, e então, endereço para o
child. Essentially, a node, and then, two filho direito. Essencialmente, um nó, e aí,
child nodes, left and right. Of course, dois nós filhos, esquerdo e direito. Claro,
there are gonna be different types of tree haverá diferentes tipos de configurações
setups that are binary, because we can de árvores que são binárias, porque nós
have multiple combinations of different podemos ter múltiplas combinações de
parent nodes to one another. nós pais diferentes entre si.
17
Transcript + Translation The Most Used Data Structures
English Português
Now, what does this mean, “level”? When Agora, o que isso significa, “nível”? Quando
you start with your root, and you start você começa com a sua raiz, e você começa
breaking down the tree, and you start a analisar a árvore, e começa a conectar
linking more and more, down to more mais e mais, abaixo para mais nós mais
nodes further on, you’ll notice that, adiante, você vai notar que, conforme
as we go down, you kind of make a nós descemos, você meio que faz uma
pyramid. You could refer to these different pirâmide. Você pode se referir a essas
hierarchies as “levels”. diferentes hierarquias como “níveis”.
18
Transcript + Translation The Most Used Data Structures
English Português
So, again, a “perfect binary tree” is... every Então, novamente, uma “árvore binária
internal node has exactly two children perfeita” é... cada nó interno tem
and they’re all on the same level. There’s exatamente dois filhos e eles estão todos
not one leaf or… I’m sorry… one external no mesmo nível. Não existe uma folha
node on the bottom of, say, a three-level ou... me desculpe... um nó externo na
decision tree, there’s not a fourth level parte inferior de, digamos, uma árvore
where one node sits by itself. de decisão de três níveis, não existe um
quarto nível onde um nó esteja sozinho.
And then, there’s a “complete binary E aí, existe uma “árvore binária completa”,
tree”, which is like a “full binary tree” que é como uma “árvore binária cheia”
with two major differences: every level com duas diferenças principais: cada nível
must be completely filled; and all the leaf deve estar completamente preenchido; e
elements (external nodes) must lean todos os elementos folha (nós externos)
towards the left. devem se inclinar para a esquerda.
19
Transcript + Translation The Most Used Data Structures
English Português
Lastly, we should discuss what kind of Por último, nós devemos discutir que tipo
operations we can do in binary trees, de operações nós podemos fazer em
because we can do a few things when árvores binárias, porque nós podemos
it comes to decision trees. Typical fazer algumas coisas quando se trata de
and most common operations include árvores de decisão. As operações típicas e
insertion and deletion, which sound pretty mais comuns incluem inserção e exclusão,
self-explanatory. que soam bastante autoexplicativas.
20
Transcript + Translation The Most Used Data Structures
English Português
English Português
What makes B-trees more useful and O que faz as árvores-B mais úteis e até
even gives them an advantage over mesmo dá a elas uma vantagem sobre
other types of tree methodologies and outros tipos de metodologias de árvores
Data Structures, (is) that B-trees and e Estruturas de Dados, (é) que árvores-B
databases keep keys in a sorted order e bancos de dados mantêm as chaves em
for sequential traversing; it also uma ordem classificada para percurso
uses a hierarchical index to minimize sequencial; ela também usa um índice
the number of disk reads; and it keeps hierárquico para minimizar o número de
the index balanced with a recursive leituras de disco; e ela mantém o índice
algorithm, meaning, it constantly goes balanceado com um algoritmo recursivo,
back through itself to the beginning and ou seja, elas retorna constantemente
reiterates this every time. através de si mesma até o início e reitera
isso todas as vezes.
You could see now the advantages of Você pôde ver agora as vantagens
how these B-trees can be, again, a de como essas árvores-B podem ser,
little complex, but yet so efficient and novamente, um pouco complexas, mas
reliable in terms of data storage and ainda assim tão eficientes e confiáveis em
data management. termos de armazenamento de dados e
gerenciamento de dados.
22
Vocabulary The Most Used Data Structures
23
Vocabulary The Most Used Data Structures
…, say, … list
Assim como “let’s say”, essa versão Lista, no sentido de uma lista de coisas a
abreviada “say” é usada quando fazer, ou também a Estrutura de Dados
queremos dar um exemplo de algo. “lista”.
Podemos traduzir como “digamos”.
when it comes to (something)
(a) stand
No que diz respeito a (algo), quanto a
Como substantivo, é um “estande”, uma (algo), no que toca a (algo).
“barraca” ou um “carrinho”, desses que
vendem comida e outras coisas nas ruas. Linked List
Lista Ligada. No contexto de Ciência da
queuing
Computação, é uma estrutura de dados
Vem da palavra “queue” (fila), mas aqui composta por vários nós interligados
a vimos como um adjetivo na expressão através de ponteiros, ou seja, cada
“queuing data structures”, que significa elemento possui um ponteiro que aponta
“estruturas de dados de fila”, ou seja, “do para o endereço de memória do próximo.
tipo fila”.
node
serving time
Nó, elemento.
Nesse contexto, indica o “tempo de
atendimento” por pessoa. address
scaling Endereço.
24
Vocabulary The Most Used Data Structures
25
Vocabulary The Most Used Data Structures
taxing final
Desgastante. Como adjetivo, significa “último” ou
“derradeiro”.
computationally taxing
binary
Desgastante em termos computacionais.
Binário.
underneath
Essa palavra significa “embaixo” ou “sob” e
binary tree
é quase um sinônimo da palavra “under”. Árvore binária. No contexto de Ciência da
Porém, ela é um pouco mais específica, Computação, é uma estrutura de dados
geralmente indicando que a coisa que na qual cada nó tem no máximo dois
está embaixo da outra está coberta, não filhos, chamados de filho esquerdo e filho
sendo possível vê-la. direito.
26
Vocabulary The Most Used Data Structures
Inclinar-se, apoiar-se.
well suited for (something)
self-explanatory Bem adequado para (algo).
Autoexplicativo.
database
unambiguously Banco de dados, base de dados.
Árvore-B.
sequential traversing
sorted O ato de realizar um percurso sequencial,
ou seja, de percorrer alguma estrutura de
Ordenado, classificado.
dados de maneira sequencial.
search
hierarchical
Busca, pesquisa.
Hierárquico.
27
Vocabulary The Most Used Data Structures
recursive to reiterate
Reiterar, no sentido de “iterar” novamente,
Recursivo.
repetir.
algorithm
data storage
Algoritmo.
Armazenamento de dados.
data management
Gerenciamento de dados.
28
Grammar The Most Used Data Structures
29
Grammar The Most Used Data Structures
30
Grammar The Most Used Data Structures
31
Grammar The Most Used Data Structures
32
Grammar The Most Used Data Structures
33
Grammar The Most Used Data Structures
Para dizer de que algo foi feito, podemos usar a estrutura “to be
made out of (something)” ou “to be composed out of (something)”,
geralmente para indicar que algo maior foi feito de coisas menores,
ou quando houve alguma transformação. Podemos traduzir como
“ser feito de (algo)” ou “ser composto de (algo)”.
34
Grammar The Most Used Data Structures
Para o verbo “to be”, por exemplo, usamos a forma “were” para
todas as conjugações, mesmo as que usam “was” no Simple Past.
Exemplos:
35
Grammar The Most Used Data Structures
36
Grammar The Most Used Data Structures
37
Grammar The Most Used Data Structures
38
Grammar The Most Used Data Structures
Como vimos na seção Vocabulary, o phrasal verb “to allow for” tem
um significado um pouco diferente de “to allow”, apesar de ambas
poderem ter a mesma tradução. Enquanto que “to allow” significa
“permitir” no sentido de dar uma permissão, uma causa e efeito; “to
allow for” significa “permitir” no sentido de “possibilitar”, “planejar”,
“deixar disponível”. Exemplo:
• The design of the system allows for easy upgrades. (O design
do sistema permite/possibilita melhorias fáceis.)
39
Mistakes The Most Used Data Structures
Em outras aulas temos professores que não são falantes nativos de inglês,
porém, nesta aula, tivemos um falante nativo, mas que mesmo assim comete
alguns errinhos, assim como nós cometemos eventualmente em português.
Isso pode te mostrar que é possível ser extremamente fluente em inglês, a
nível de trabalhar e fazer apresentações no idioma, e mesmo assim cometer
pequenos errinhos.
Nesta seção, vamos explicar quais foram esses errinhos cometidos durante a
aula e como corrigi-los.
Explicação: Ambas as frases fazem sentido, mas temos que ser coerentes - ou usamos
“element” e “is” no singular, ou “elements” e “are” no plural.
C+
Frase correta: C++
Explicação: O nome da linguagem é C plus plus, com dois sinais de adição. O instrutor
pode ter feito simplesmente uma abreviação do nome também.
40
Mistakes The Most Used Data Structures
Explicação: Como a próxima palavra começa em som de vogal, o correto seria usar o
artigo indefinido “an”. O instrutor provavelmente mudou sua linha de pensamento no
meio da frase.
Explicação: Tanto “a lot” quanto “methodologies” pedem uma conjugação no plural, por
isso precisamos do “there are” também no plural, mas é um erro muito comum na fala,
mesmo entre nativos.
Explicação: Como temos “two” no plural, precisamos da conjugação “there are” também
no plural, mas é um erro muito comum na fala, mesmo entre nativos.
Explicação: Tanto “a lot” quanto “types” pedem uma conjugação no plural, por isso
precisamos do “there are” também no plural, mas é um erro muito comum na fala,
mesmo entre nativos.
Além disso, é mais correto o uso de um verbo depois de “one”, em vez de seu uso
sozinho. Por isso, é melhor usar “one that is…”.
41
Mistakes The Most Used Data Structures
Explicação: A frase “not to be confused” é usada para fazer uma comparação com
outra coisa, por isso é mais natural adicionar o “with” e essa comparação. O instrutor
provavelmente mudou sua linha de pensamento no meio da frase.
42