1 00:00:06,490 --> 00:00:10,720 Now that we know what a stack is, we can start talking about a queue. 2 00:00:10,840 --> 00:00:18,790 And a queue is very, very similar to a stack because it's also dependent upon a specific order. 3 00:00:19,120 --> 00:00:28,390 So remember, a stack was LIFO last in first out, a queue instead of being LIFO. 4 00:00:28,450 --> 00:00:31,780 A queue is going to be FIFO. 5 00:00:32,890 --> 00:00:41,440 And you might can guess what this is, but this is first in first. 6 00:00:42,660 --> 00:00:52,650 LB So if we visualize this and we put our cue here and we push ten, we have ten. 7 00:00:54,030 --> 00:00:55,390 Push 20. 8 00:00:55,410 --> 00:00:56,580 We have 20. 9 00:00:58,290 --> 00:00:59,580 Push 30. 10 00:00:59,850 --> 00:01:00,960 We have 30. 11 00:01:03,120 --> 00:01:04,310 Push 40. 12 00:01:04,320 --> 00:01:05,700 We have 40. 13 00:01:06,090 --> 00:01:10,230 And now if we call Pop, ten is gone. 14 00:01:10,650 --> 00:01:14,520 If we call pop again, 20 is gone. 15 00:01:14,760 --> 00:01:20,610 If we push, 50, 50 is there. 16 00:01:20,940 --> 00:01:26,160 And if we pop one more time now, 30 is gone. 17 00:01:26,790 --> 00:01:29,540 So that is first in, first out. 18 00:01:29,550 --> 00:01:34,680 Basically, the oldest item in the queue is taken out. 19 00:01:35,130 --> 00:01:38,730 So when would something like this be useful? 20 00:01:40,170 --> 00:01:43,560 Well, I just kind of said it when we want. 21 00:01:46,540 --> 00:01:47,740 The oldest item. 22 00:01:52,750 --> 00:01:55,090 Item taken care of. 23 00:01:58,220 --> 00:02:00,200 So think of this like a line. 24 00:02:01,160 --> 00:02:04,010 You're standing in line at a store trying to pay. 25 00:02:05,120 --> 00:02:11,240 Well, the longer you stand in line, you would like to hope that your position in line is getting closer 26 00:02:11,240 --> 00:02:15,440 and closer to actually being able to pay for your item and check out. 27 00:02:16,220 --> 00:02:17,720 And that is what a queue is. 28 00:02:18,320 --> 00:02:24,320 Once you're in that line, you will eventually be the first one that was in the line. 29 00:02:24,530 --> 00:02:27,740 So you will become the first one out of the line. 30 00:02:27,740 --> 00:02:31,340 So when we want to get the oldest item taken care of. 31 00:02:31,790 --> 00:02:37,550 And now that we know what a queue is and that we also know that it's going to be very similar to a stack. 32 00:02:37,550 --> 00:02:44,030 But instead of being like, Oh, we're going to be FIFO, we're going to go implement our own queue 33 00:02:44,030 --> 00:02:45,620 so that we can visualize. 34 00:02:46,710 --> 00:02:51,330 How a QR code differs from a Stax. 35 00:02:51,600 --> 00:02:55,890 So in the next lecture, we will begin implementing our own Q.