youtube-transcript.ai

Learn Queue data structures in 10 minutes 🎟️

Watch with subtitles, summary & AI chat
Add the free Subkun extension — works directly on YouTube.
  • Watch
  • Subtitles
  • Summary
  • Ask AI
Try free →

A queue is a First-In, First-Out (FIFO) data structure used in computer science to hold elements before processing, much like a real-world waiting line. Key operations include `offer` (enqueue) to add elements to the tail and `poll` (dequeue) to remove elements from the head, with `peek` to view the head element without removal.

Full Transcript (Bilingual)

https://www.youtube.com/watch?v=nqXaPZi99JI
Translation: pt-BR

[00:00] hey what's going on everybody it's you
Ei, o que está acontecendo, pessoal? Sou eu

[00:02] hey what's going on everybody it's you bro hope you're doing well
Ei, o que está acontecendo, pessoal? Sou eu, mano. Espero que você esteja bem

[00:03] bro hope you're doing well in this video i'm going to explain cues
Mano, espero que você esteja bem. Neste vídeo, vou explicar filas

[00:05] in this video i'm going to explain cues in computer science
Neste vídeo, vou explicar filas em ciência da computação

[00:06] in computer science so sit back relax and enjoy the show
Em ciência da computação, então sente-se, relaxe e aproveite o show

[00:11] if you find this video helpful please
Se você achar este vídeo útil, por favor

[00:12] if you find this video helpful please remember to like
Se você achar este vídeo útil, por favor, lembre-se de curtir

[00:14] remember to like comment and subscribe your support will
Lembre-se de curtir, comentar e se inscrever. Seu apoio vai

[00:16] comment and subscribe your support will help keep this channel running
Comentar e se inscrever. Seu apoio ajudará a manter este canal funcionando

[00:18] help keep this channel running whoa hey we're talking about cues today
Ajudará a manter este canal funcionando. Uau, ei, estamos falando sobre filas hoje

[00:21] whoa hey we're talking about cues today so cues
Uau, ei, estamos falando sobre filas hoje. Então, filas

[00:21] so cues are a fifo data structure not to be
Então, filas são uma estrutura de dados FIFO, para não ser

[00:24] are a fifo data structure not to be confused with fifa
São uma estrutura de dados FIFO, para não ser confundida com FIFA

[00:25] confused with fifa fifo as in first in first out an example
Confundida com FIFA. FIFO, como em First In, First Out. Um exemplo

[00:28] fifo as in first in first out an example would be a line of people it's first
FIFO, como em First In, First Out. Um exemplo seria uma fila de pessoas. É o primeiro

[00:30] would be a line of people it's first come first serve whoever's there first
Seria uma fila de pessoas. É o primeiro a chegar, o primeiro a ser servido. Quem estiver lá primeiro

[00:32] come first serve whoever's there first gets helped first
A chegar, o primeiro a ser servido. Quem estiver lá primeiro é ajudado primeiro

[00:33] gets helped first so this is a collection designed for
É ajudado primeiro. Então, esta é uma coleção projetada para

[00:35] so this is a collection designed for holding elements prior to processing
Então, esta é uma coleção projetada para manter elementos antes do processamento

[00:37] holding elements prior to processing it's a linear data structure here's an
Manter elementos antes do processamento. É uma estrutura de dados linear. Aqui está um

[00:39] it's a linear data structure here's an example imagine that we're a cashier and
É uma estrutura de dados linear. Aqui está um exemplo. Imagine que somos um caixa e

[00:41] example imagine that we're a cashier and we're selling tickets to a concert we
Exemplo. Imagine que somos um caixa e estamos vendendo ingressos para um show. Nós

[00:43] we're selling tickets to a concert we will help
Estamos vendendo ingressos para um show. Nós ajudaremos

[00:44] will help whoever approaches our register first
Ajudaremos quem se aproximar do nosso caixa primeiro

[00:46] whoever approaches our register first it's first come
Quem se aproximar do nosso caixa primeiro. É o primeiro a chegar

[00:47] it's first come first serve in other words it's fifo
É o primeiro a chegar, o primeiro a ser servido. Em outras palavras, é FIFO

[00:50] first serve in other words it's fifo
O primeiro a ser servido. Em outras palavras, é FIFO

[00:50] first in first out unfortunately a wild karen
First In, First Out. Infelizmente, uma Karen selvagem

[00:53] first out unfortunately a wild karen appears and she would like to talk to
First Out. Infelizmente, uma Karen selvagem aparece e ela gostaria de falar com

[00:54] appears and she would like to talk to the manager
Aparece e ela gostaria de falar com o gerente

[00:55] the manager now karen is going to waste everybody's
O gerente. Agora, Karen vai desperdiçar o tempo de todo mundo

[00:57] now karen is going to waste everybody's time so it's going to be a while
Agora, Karen vai desperdiçar o tempo de todo mundo, então vai demorar um pouco

[00:59] time so it's going to be a while in the meantime chad enters the line he
Tempo. Então, vai demorar um pouco. Enquanto isso, Chad entra na fila. Ele

[01:01] in the meantime chad enters the line he will enter in at the back and wait his
enquanto isso chad entra na fila ele entrará no final e esperará sua

[01:02] will enter in at the back and wait his turn
vez entrará no final e esperará sua vez

[01:03] turn followed by steve and then harold so
vez seguido por steve e depois harold então

[01:06] followed by steve and then harold so karen is at the head of our queue
seguido por steve e depois harold então karen está no início da nossa fila

[01:07] karen is at the head of our queue our line and harold is all the way at
karen está no início da nossa fila nossa linha e harold está todo o caminho no

[01:09] our line and harold is all the way at the back our tail
nossa linha e harold está todo o caminho no final nossa cauda

[01:11] the back our tail as you can see harold is very anxious
final nossa cauda como você pode ver harold está muito ansioso

[01:13] as you can see harold is very anxious right now once karen has been defeated
como você pode ver harold está muito ansioso agora que karen foi derrotada

[01:15] right now once karen has been defeated chad will move to the head of our queue
agora que karen foi derrotada chad se moverá para o início da nossa fila

[01:18] chad will move to the head of our queue so
chad se moverá para o início da nossa fila então

[01:18] so chad will now be helped next and harold
então chad agora será atendido em seguida e harold

[01:21] chad will now be helped next and harold will still be at the tail until somebody
chad agora será atendido em seguida e harold ainda estará na cauda até que alguém

[01:23] will still be at the tail until somebody else enters the line
ainda estará na cauda até que alguém mais entre na fila

[01:24] else enters the line once chad has been helped he will move
mais entre na fila uma vez que chad for ajudado ele se moverá

[01:26] once chad has been helped he will move out of our queue
uma vez que chad for ajudado ele sairá da nossa fila

[01:27] out of our queue and steve is at the head now and the
da nossa fila e steve está no início agora e a

[01:30] and steve is at the head now and the tail will move as well
e steve está no início agora e a cauda também se moverá

[01:31] tail will move as well and then once steve has been held harold
cauda também se moverá e então uma vez que steve for atendido harold

[01:35] and then once steve has been held harold is the only one currently waiting in
e então uma vez que steve for atendido harold é o único atualmente esperando em

[01:36] is the only one currently waiting in line for his tickets he will be at both
é o único atualmente esperando na fila por seus ingressos ele estará em ambos

[01:38] line for his tickets he will be at both the head and
fila por seus ingressos ele estará em ambos o início e

[01:39] the head and the tail of our queue so that's kind of
o final da nossa fila então isso é meio que

[01:41] the tail of our queue so that's kind of how a queue works it's first come
o final da nossa fila então é assim que uma fila funciona é primeiro a chegar

[01:43] how a queue works it's first come first serve fifo first in first out if
que uma fila funciona é primeiro a chegar primeiro a ser servido fifo primeiro a entrar primeiro a sair se

[01:45] first serve fifo first in first out if you were here first then you will be
primeiro a ser servido fifo primeiro a entrar primeiro a sair se você chegou primeiro então você será

[01:47] you were here first then you will be helped first
você chegou primeiro então você será ajudado primeiro

[01:48] helped first now the concepts of adding and removing
ajudado primeiro agora os conceitos de adicionar e remover

[01:50] now the concepts of adding and removing objects from a queue are known as both
agora os conceitos de adicionar e remover objetos de uma fila são conhecidos como ambos

[01:53] objects from a queue are known as both enqueuing and dequeueing enqueuing is
objetos de uma fila são conhecidos como ambos enfileirar e desenfileirar enfileirar é

[01:55] enqueuing and dequeueing enqueuing is the concept of adding an object
enfileirar e desenfileirar enfileirar é o conceito de adicionar um objeto

[01:57] the concept of adding an object to the end of our cue our tail and
o conceito de adicionar um objeto ao final da nossa fila nossa cauda e

[02:00] to the end of our cue our tail and dequeueing
ao final da nossa fila nossa cauda e desenfileirar

[02:01] dequeueing is when we remove an object from the head of our queue.
O kuyruktan bir nesneyi çıkarmak olduğunda.

[02:04] Now what methods do you need to enqueue and dq from a queue?
Şimdi bir kuyruğa eklemek ve kuyruktan çıkarmak için hangi yöntemlere ihtiyacınız var?

[02:08] Well it really depends on the programming language that you're working with.
Pekala, bu gerçekten üzerinde çalıştığınız programlama diline bağlıdır.

[02:11] A lot of you voted for data structures and algorithms using Java, so I'll probably stick with Java then.
Birçoğunuz Java kullanarak veri yapıları ve algoritmalar için oy kullandınız, bu yüzden muhtemelen Java ile devam edeceğim.

[02:16] Here's an example now to enqueue and dq.
Şimdi eklemek ve çıkarmak için bir örnek.

[02:19] We need, well, a queue, so let's create one.
İhtiyacımız var, peki, bir kuyruk, o zaman bir tane oluşturalım.

[02:23] Then we need to list the data type of the objects that we're going to add to this queue.
O zaman bu kuyruğa ekleyeceğimiz nesnelerin veri türünü listelememiz gerekiyor.

[02:27] Let's work with strings because strings are objects and they're fairly simple.
Dizelerle çalışalım çünkü dizeler nesnelerdir ve oldukça basittirler.

[02:31] And I will name this queue q equals new.
Ve bu kuyruğa q eşittir yeni adını vereceğim.

[02:34] Now check this out, I will attempt to create a queue object and instantiate it.
Şimdi şunu kontrol edin, bir kuyruk nesnesi oluşturmaya ve örneklemeye çalışacağım.

[02:38] And the data type is string and I will add a constructor.
Ve veri türü dizedir ve bir oluşturucu ekleyeceğim.

[02:42] Now we cannot instantiate the type q.
Şimdi q türünü örnekleyemeyiz.

[02:44] Here's the reason why.
İşte nedeni bu.

[02:46] So if we take a look at the queue class right here, q is actually an interface and not a class.
Yani buradaki kuyruk sınıfına bakarsak, q aslında bir sınıftan ziyade bir arayüzdür.

[02:52] And based on our lesson on interfaces, we cannot create an instance of an interface.
Ve arayüzler üzerine yaptığımız derse dayanarak, bir arayüzün örneğini oluşturamayız.

[02:58] An interface is meant to be more of like a template that we can apply to another.
Bir arayüz, daha çok başka bir şeye uygulayabileceğimiz bir şablon gibi tasarlanmıştır.

[03:02] a template that we can apply to another class.
um modelo que podemos aplicar a outra classe.

[03:03] class so to utilize q technology we need a class.
classe, então, para utilizar a tecnologia q, precisamos de uma classe.

[03:05] so to utilize q technology we need a class that implements q.
então, para utilizar a tecnologia q, precisamos de uma classe que implemente q.

[03:06] now taking a look at that implements q.
agora, dando uma olhada que implementa q.

[03:09] now taking a look at our java collections hierarchy.
agora, dando uma olhada em nossa hierarquia de coleções Java.

[03:11] our java collections hierarchy there are two classes that implement cues.
nossa hierarquia de coleções Java, existem duas classes que implementam filas.

[03:13] there are two classes that implement cues one of which is the linked list.
existem duas classes que implementam filas, uma delas é a lista ligada.

[03:16] cues one of which is the linked list and the other is the priority queue now.
filas, uma delas é a lista ligada e a outra é a fila de prioridade agora.

[03:18] and the other is the priority queue now priority queues they will rearrange their elements based on a certain priority.
e a outra é a fila de prioridade agora, filas de prioridade, elas reorganizarão seus elementos com base em uma certa prioridade.

[03:20] priority queues they will rearrange their elements based on a certain priority.
filas de prioridade, elas reorganizarão seus elementos com base em uma certa prioridade.

[03:21] their elements based on a certain priority.
seus elementos com base em uma certa prioridade.

[03:22] priority so they wouldn't be a good example so to utilize the features of a queue.
prioridade, então não seriam um bom exemplo, então para utilizar os recursos de uma fila.

[03:25] so to utilize the features of a queue we are going to create a linked list.
então, para utilizar os recursos de uma fila, vamos criar uma lista ligada.

[03:26] utilize the features of a queue we are going to create a linked list because we cannot instantiate a queue.
utilizar os recursos de uma fila, vamos criar uma lista ligada porque não podemos instanciar uma fila.

[03:28] because we cannot instantiate a queue itself because it's an interface.
porque não podemos instanciar uma fila em si, porque é uma interface.

[03:30] itself because it's an interface with that being said let's change equals.
em si, porque é uma interface, com isso dito, vamos mudar equals.

[03:32] with that being said let's change equals new q to equals new linked list.
com isso dito, vamos mudar equals new q para equals new linked list.

[03:35] new q to equals new linked list.
new q para equals new linked list.

[03:36] to equals new linked list we won't be focusing on any of the features of linked lists.
para equals new linked list, não vamos focar em nenhum dos recursos de listas ligadas.

[03:39] we won't be focusing on any of the features of linked lists we'll save that for another video maybe the next one.
não vamos focar em nenhum dos recursos de listas ligadas, vamos guardar isso para outro vídeo, talvez o próximo.

[03:41] features of linked lists we'll save that for another video maybe the next one i haven't decided.
recursos de listas ligadas, vamos guardar isso para outro vídeo, talvez o próximo, eu não decidi.

[03:43] for another video maybe the next one i haven't decided yet so we will only cover the features that linked lists will utilize via the q interface.
para outro vídeo, talvez o próximo, eu não decidi ainda, então cobriremos apenas os recursos que listas ligadas utilizarão através da interface q.

[03:45] haven't decided yet so we will only cover the features that linked lists will utilize via the q interface.
não decidi ainda, então cobriremos apenas os recursos que listas ligadas utilizarão através da interface q.

[03:46] yet so we will only cover the features that linked lists will utilize via the q interface.
ainda, então cobriremos apenas os recursos que listas ligadas utilizarão através da interface q.

[03:49] now with the q interface there are three methods that we inherit from the collections parent class.
agora, com a interface q, existem três métodos que herdamos da classe pai collections.

[03:52] interface now with the q interface there are three methods that we inherit from the collections parent class.
interface, agora, com a interface q, existem três métodos que herdamos da classe pai collections.

[03:55] there are three methods that we inherit from the collections parent class add remove and element.
existem três métodos que herdamos da classe pai collections: add, remove e element.

[03:57] from the collections parent class add remove and element these will do.
da classe pai collections: add, remove e element. estes farão.

[04:00] add remove and element these will do.
add, remove e element. estes farão.

[04:02] add remove and element these will do approximately the same thing
adicionar remover e elemento, estes farão aproximadamente a mesma coisa

[04:04] approximately the same thing as enqueuing dequeuing and peaking at
aproximadamente a mesma coisa que enfileirar, desenfileirar e espiar

[04:07] as enqueuing dequeuing and peaking at the topmost element
como enfileirar, desenfileirar e espiar o elemento do topo

[04:08] the topmost element however they throw exceptions and
o elemento do topo, no entanto, eles lançam exceções e

[04:10] however they throw exceptions and according to the documentation
no entanto, eles lançam exceções e, de acordo com a documentação

[04:12] according to the documentation it's actually better to use this column
de acordo com a documentação, é realmente melhor usar esta coluna

[04:14] it's actually better to use this column of methods instead
é realmente melhor usar esta coluna de métodos em vez disso

[04:15] of methods instead these will return a special value we
de métodos em vez disso, estes retornarão um valor especial nós

[04:18] these will return a special value we have offer
estes retornarão um valor especial nós temos offer

[04:19] have offer which will enqueue or add an element to
temos offer que enfileirará ou adicionará um elemento a

[04:21] which will enqueue or add an element to the
que enfileirará ou adicionará um elemento ao

[04:22] the tail of our queue poll will dequeue
a cauda da nossa fila poll desenfileirará

[04:25] tail of our queue poll will dequeue it will remove the head of our current
cauda da nossa fila poll desenfileirará, removerá a cabeça da nossa atual

[04:28] it will remove the head of our current queue and
removerá a cabeça da nossa fila atual e

[04:28] queue and then there is also peak it will not
fila e então há também peak, não removerá

[04:31] then there is also peak it will not remove the head but it will examine it
então há também peak, não removerá a cabeça, mas a examinará

[04:33] remove the head but it will examine it and return it so those are the three
remover a cabeça, mas a examinará e retornará, então esses são os três

[04:35] and return it so those are the three dedicated methods
e retorná-la, então esses são os três métodos dedicados

[04:37] dedicated methods that we implement via the queue
métodos dedicados que implementamos através da fila

[04:39] that we implement via the queue interface there are some additional
que implementamos através da interface de fila, há alguns adicionais

[04:40] interface there are some additional methods too which we'll cover later
interface, há também alguns métodos adicionais que cobriremos mais tarde

[04:42] methods too which we'll cover later which we inherit from the collections
métodos também que cobriremos mais tarde, que herdamos das coleções

[04:44] which we inherit from the collections class so let's begin
que herdamos da classe collections, então vamos começar

[04:46] class so let's begin by offering a bunch of people to our
classe, então vamos começar oferecendo um monte de pessoas à nossa

[04:48] by offering a bunch of people to our queue this is how we enqueue or add
oferecendo um monte de pessoas à nossa fila, é assim que enfileiramos ou adicionamos

[04:50] queue this is how we enqueue or add elements to our queue so first in our
fila, é assim que enfileiramos ou adicionamos elementos à nossa fila, então primeiro em nossa

[04:53] elements to our queue so first in our line we have karen
elementos à nossa fila, então primeiro em nossa fila temos karen

[04:54] line we have karen so to add her to the queue we would type
fila temos karen, então para adicioná-la à fila digitaríamos

[04:57] so to add her to the queue we would type the name of our queue
então para adicioná-la à fila digitaríamos o nome da nossa fila

[04:58] the name of our queue q dot offer
o nome da nossa fila q ponto offer

[05:01] q dot offer and we will offer karen to the front of
q ponto offer e ofereceremos karen à frente de

[05:04] and we will offer karen to the front of our queue and she would like to complain
e ofereceremos karen no início da nossa fila e ela gostaria de reclamar

[05:05] our queue and she would like to complain to the manager
nossa fila e ela gostaria de reclamar com o gerente

[05:07] to the manager next we have chad q dot offer
ao gerente em seguida temos chad q ponto oferta

[05:12] chad then we have steve
chad então temos steve

[05:17] and lastly harold
e por último harold

[05:22] okay now if we were to display our cue
ok agora se fôssemos exibir nossa fila

[05:25] okay now if we were to display our cue we'll place it within a print line
ok agora se fôssemos exibir nossa fila a colocaremos dentro de uma linha de impressão

[05:27] we'll place it within a print line statement we will pass in
a colocaremos dentro de uma instrução de linha de impressão passaremos

[05:29] statement we will pass in q as an argument and this should display
instrução passaremos q como argumento e isso deve exibir

[05:31] q as an argument and this should display our q in order
q como argumento e isso deve exibir nossa fila em ordem

[05:33] our q in order first we have karen at the head then
nossa fila em ordem primeiro temos karen na cabeça então

[05:35] first we have karen at the head then chad
primeiro temos karen na cabeça então chad

[05:36] chad steve then harold at the tail one method
chad steve então harold na cauda um método

[05:38] steve then harold at the tail one method that we implement
steve então harold na cauda um método que implementamos

[05:39] that we implement from the q interface is the peak method
que implementamos da interface q é o método peak

[05:43] from the q interface is the peak method we can use the peak method to examine
da interface q é o método peak podemos usar o método peak para examinar

[05:45] we can use the peak method to examine and take a look at the object
podemos usar o método peak para examinar e dar uma olhada no objeto

[05:47] and take a look at the object at the head of our queue we're not
e dar uma olhada no objeto na cabeça da nossa fila não vamos

[05:49] at the head of our queue we're not actually going to remove
na cabeça da nossa fila não vamos realmente remover

[05:50] actually going to remove the object at the head of the cube but
realmente remover o objeto na cabeça do cubo mas

[05:52] the object at the head of the cube but take a look at it so within
o objeto na cabeça do cubo mas dar uma olhada nele então dentro

[05:54] take a look at it so within a print line statement i will use q
dar uma olhada nele então dentro de uma instrução de linha de impressão usarei q

[05:57] a print line statement i will use q dot peak method and after peaking over
uma instrução de linha de impressão usarei o método q ponto peak e depois de olhar por cima

[06:00] dot peak method and after peaking over our cash register
método ponto peak e depois de olhar por cima do nosso caixa

[06:01] our cash register unfortunately karen is at the front of
nosso caixa infelizmente karen está na frente

[06:03] unfortunately karen is at the front of the line now
infelizmente karen está na frente da fila agora

[06:05] the line now to dq we can use the pull method
a linha agora para dq podemos usar o método pull

[06:08] to dq we can use the pull method so type q dot poll
para dq podemos usar o método pull então digite q ponto poll

[06:12] so type q dot poll and this will dequeue your q
então digite q ponto poll e isso irá desenfileirar sua fila

[06:15] and this will dequeue your q so karen is no longer at the head of our
e isso irá desenfileirar sua fila então karen não está mais na cabeça da nossa

[06:18] so karen is no longer at the head of our queue so let's pull a couple more times
então karen não está mais na cabeça da nossa fila então vamos puxar mais algumas vezes

[06:20] queue so let's pull a couple more times for practice
fila então vamos puxar mais algumas vezes para praticar

[06:21] for practice so after polling twice karen and chad
para praticar então depois de votar duas vezes karen e chad

[06:25] so after polling twice karen and chad are now
então depois de votar duas vezes karen e chad agora

[06:25] are now gone using pull a third time will remove
se foram usando pull uma terceira vez removerá

[06:29] gone using pull a third time will remove steve and lastly
se foram usando pull uma terceira vez removerá steve e por último

[06:33] steve and lastly now the nice thing about the poll method
steve e por último agora a coisa boa sobre o método pull

[06:35] now the nice thing about the poll method is that it will not cause an exception
agora a coisa boa sobre o método pull é que ele não causará uma exceção

[06:38] is that it will not cause an exception according to the java documentation you
é que ele não causará uma exceção de acordo com a documentação do java você

[06:40] according to the java documentation you can use element to peak
de acordo com a documentação do java você pode usar element para espiar

[06:42] can use element to peak but it will throw an exception so if i
pode usar element para espiar mas lançará uma exceção então se eu

[06:44] but it will throw an exception so if i was to use
mas lançará uma exceção então se eu fosse usar

[06:45] was to use element at the end this would cause an
fosse usar element no final isso causaria um

[06:48] element at the end this would cause an exception then
element no final isso causaria uma exceção então

[06:49] exception then so usually it's preferable to use this
exceção então geralmente é preferível usar este

[06:52] so usually it's preferable to use this column of methods even though they're
então geralmente é preferível usar esta coluna de métodos embora eles sejam

[06:53] column of methods even though they're similar
coluna de métodos embora sejam semelhantes

[06:54] similar these will not throw exceptions offer
semelhantes estes não lançarão exceções oferecem

[06:56] these will not throw exceptions offer pull and peek now with cues there are
estes não lançarão exceções oferecem pull e peek agora com filas existem

[06:58] pull and peek now with cues there are some additional methods that you might
pull e peek agora com filas existem alguns métodos adicionais que você pode

[07:00] some additional methods that you might be interested in
alguns métodos adicionais que você pode estar interessado em

[07:01] be interested in the q class will extend the collection
estar interessado em a classe q estenderá a coleção

[07:04] the q class will extend the collection class
a classe q estenderá a classe collection

[07:04] class so the q class inherits everything that
classe então a classe q herda tudo que

[07:06] so the q class inherits everything that the collection class has
então a classe q herda tudo o que a classe collection tem

[07:08] the collection class has and there's some pretty useful methods
a classe collection tem e há alguns métodos muito úteis

[07:09] and there's some pretty useful methods within here i'll show you a few
e há alguns métodos muito úteis aqui dentro, vou mostrar alguns

[07:11] within here i'll show you a few so the first is that we can check to see
aqui dentro, vou mostrar alguns, então o primeiro é que podemos verificar

[07:13] so the first is that we can check to see if our queue is empty
então o primeiro é que podemos verificar se nossa fila está vazia

[07:15] if our queue is empty so within a print line statement i will
se nossa fila está vazia, então dentro de uma instrução de impressão eu vou

[07:17] so within a print line statement i will type q
então dentro de uma instrução de impressão eu vou digitar q

[07:19] type q dot is empty and if our queue is empty
digitar q ponto is empty e se nossa fila está vazia

[07:23] dot is empty and if our queue is empty this will return true
ponto is empty e se nossa fila está vazia, isso retornará true

[07:24] this will return true so if i move this line of code after we
isso retornará true, então se eu mover esta linha de código depois que nós

[07:27] so if i move this line of code after we offer a bunch of
então se eu mover esta linha de código depois que nós oferecermos um monte de

[07:28] offer a bunch of strings a bunch of people to our queue
oferecermos um monte de strings, um monte de pessoas para nossa fila

[07:30] strings a bunch of people to our queue if we check to see if our queue is empty
strings, um monte de pessoas para nossa fila, se verificarmos se nossa fila está vazia

[07:33] if we check to see if our queue is empty that will be false there are people
se verificarmos se nossa fila está vazia, isso será falso, há pessoas

[07:35] that will be false there are people currently within our line
isso será falso, há pessoas atualmente em nossa linha

[07:37] currently within our line so that is the is md method we can also
atualmente em nossa linha, então esse é o método is empty, também podemos

[07:40] so that is the is md method we can also check to see
então esse é o método is empty, também podemos verificar

[07:40] check to see the size of our queue how long is our
verificar o tamanho de nossa fila, quão longa é nossa

[07:43] the size of our queue how long is our line system.out.printline
o tamanho de nossa fila, quão longa é nossa linha system.out.println

[07:45] line system.out.printline q dot size and the size of our line
linha system.out.println q ponto size e o tamanho de nossa linha

[07:49] q dot size and the size of our line our q is four four objects we have four
q ponto size e o tamanho de nossa linha, nossa q é quatro, quatro objetos, temos quatro

[07:52] our q is four four objects we have four people waiting in line to be helped
nossa q é quatro, quatro objetos, temos quatro pessoas esperando na fila para serem ajudadas

[07:54] people waiting in line to be helped so that is the size method and another
pessoas esperando na fila para serem ajudadas, então esse é o método size e outro

[07:57] so that is the size method and another is the contains method
então esse é o método size e outro é o método contains

[07:58] is the contains method we can check to see if our queue has a
é o método contains, podemos verificar se nossa fila tem um

[08:01] we can check to see if our queue has a certain object that we're looking for
podemos verificar se nossa fila tem um certo objeto que estamos procurando

[08:03] certain object that we're looking for so within a print line statement i will
certo objeto que estamos procurando, então dentro de uma instrução de impressão eu vou

[08:05] so within a print line statement i will type
então dentro de uma instrução de impressão eu vou digitar

[08:06] type q dot contains and then pass in an
digitar q ponto contains e então passar um

[08:09] q dot contains and then pass in an object.
q.contém e então passa um objeto.

[08:10] object let's check to see if harold is at the back of the line.
objeto, vamos verificar se Harold está no final da fila.

[08:11] he's been waiting here patiently.
ele está esperando aqui pacientemente.

[08:14] q dot contains herald and according to the contains method.
q.contém herald e, de acordo com o método contains.

[08:18] herald is in fact within our line that is true.
herald está de fato em nossa fila, isso é verdade.

[08:21] however this method does not give the index the position in which herald is in.
no entanto, este método não fornece o índice, a posição em que herald está.

[08:26] imagine that we yell out hey harold are you there and he yells back yeah or true.
imagine que gritamos: ei Harold, você está aí? e ele grita de volta: sim ou verdadeiro.

[08:33] that's kind of how the contains method works.
é mais ou menos como o método contains funciona.

[08:34] so these are three useful methods that cues inherit from the collection class.
então estes são três métodos úteis que as filas herdam da classe collection.

[08:40] now where could cues be useful.
agora, onde as filas podem ser úteis?

[08:41] they're actually used in quite a number of things but here's a few examples that came to mind.
eles são realmente usados em várias coisas, mas aqui estão alguns exemplos que me vieram à mente.

[08:45] so one that can be used in keyboard buffers.
então um que pode ser usado em buffers de teclado.

[08:47] have you ever typed so fast that the computer couldn't render all the characters onto the screen.
você já digitou tão rápido que o computador não conseguiu renderizar todos os caracteres na tela?

[08:53] and all of those characters were added to a buffer.
e todos esses caracteres foram adicionados a um buffer.

[08:57] they were all displayed in sequence and they were waiting for their turn to be displayed.
eles foram todos exibidos em sequência e estavam esperando sua vez de serem exibidos.

[08:59] so with a keyboard buffer letters should appear on the screen in the order that they're pressed right.
então, com um buffer de teclado, as letras devem aparecer na tela na ordem em que são pressionadas, certo?

[09:05] first in first out.
primeiro a entrar, primeiro a sair.

[09:06] they're also used in printer cues.
eles também são usados em filas de impressora.

[09:09] print jobs should be completed.
trabalhos de impressão devem ser concluídos.

[09:10] Jobs should be completed in order so we would start with page one.
Os trabalhos devem ser concluídos em ordem, então começaríamos com a página um.

[09:12] In order so we would start with page one then page two.
Em ordem, então começaríamos com a página um, depois a página dois.

[09:13] Then page two and just follow that pattern and as we discussed before.
Então a página dois e apenas siga esse padrão e, como discutimos antes.

[09:15] And just follow that pattern and as we discussed before they're used in linked lists, priority queues as well as breadth.
E apenas siga esse padrão e, como discutimos antes, eles são usados em listas ligadas, filas de prioridade, bem como em largura.

[09:17] Discussed before they're used in linked lists, priority queues as well as breadth first search algorithms.
Discutimos antes, eles são usados em listas ligadas, filas de prioridade, bem como em algoritmos de busca em largura.

[09:21] Breadth first search algorithms well everybody in conclusion.
Algoritmos de busca em largura, bem, todos, em conclusão.

[09:23] In conclusion a queue is a FIFO data structure first in.
Em conclusão, uma fila é uma estrutura de dados FIFO, primeiro a entrar.

[09:27] A queue is a FIFO data structure first in first out.
Uma fila é uma estrutura de dados FIFO, primeiro a entrar, primeiro a sair.

[09:28] First out it's a collection designed for holding elements prior to some sort of processing.
Primeiro a sair, é uma coleção projetada para conter elementos antes de algum tipo de processamento.

[09:31] It's a collection designed for holding elements prior to some sort of processing it's a linear data structure.
É uma coleção projetada para conter elementos antes de algum tipo de processamento, é uma estrutura de dados linear.

[09:34] Linear data structure imagine a bunch of people waiting in line to enqueue.
Estrutura de dados linear, imagine um monte de gente esperando na fila para enfileirar.

[09:36] Imagine a bunch of people waiting in line to enqueue that means to add an element to the tail.
Imagine um monte de gente esperando na fila para enfileirar, isso significa adicionar um elemento à cauda.

[09:39] That means to add an element to the tail of our queue to the end.
Isso significa adicionar um elemento à cauda da nossa fila, ao fim.

[09:42] Of our queue to the end we can use the offer method in Java to dequeue.
Da nossa fila, ao fim, podemos usar o método offer em Java para remover da fila.

[09:44] We can use the offer method in Java to dequeue we would use the poll method in Java.
Podemos usar o método offer em Java para remover da fila, usaríamos o método poll em Java.

[09:47] Dequeue we would use the poll method in Java that will remove the element at the head.
Remover da fila, usaríamos o método poll em Java, que removerá o elemento na cabeça.

[09:50] That will remove the element at the head of our queue.
Que removerá o elemento na cabeça da nossa fila.

[09:50] Of our queue so that is the queue data structure in the comments down below.
Da nossa fila, então essa é a estrutura de dados de fila nos comentários abaixo.

[09:53] So that is the queue data structure in the comments down below let me know what you would tell Karen if.
Então essa é a estrutura de dados de fila nos comentários abaixo, me diga o que você diria a Karen se.

[09:56] Comments down below let me know what you would tell Karen if she asked to speak with your manager.
Comentários abaixo, me diga o que você diria a Karen se ela pedisse para falar com seu gerente.

[09:57] Let me know what you would tell Karen if she asked to speak with your manager and that ladies and gentlemen is the queue.
Me diga o que você diria a Karen se ela pedisse para falar com seu gerente e isso, senhoras e senhores, é a fila.

[09:59] And that ladies and gentlemen is the queue data structure in the field of computer.
E isso, senhoras e senhores, é a estrutura de dados de fila no campo da computação.

[10:01] Data structure in the field of computer science.
Estrutura de dados na área de ciência da computação.

Cite this page

If you're using ChatGPT, Claude, Gemini, or another AI assistant, paste this URL into the chat:

https://youtube-transcript.ai/docs/learn-queue-data-structures-in-10-minutes-u5knfs7bsc

The full transcript and summary on this page will be retrieved as context, so the assistant can answer questions about the video accurately.