Queue and FIFO/FCFS explained in 10 minutes + a bonus task 📣📣 (Data Structures course)

preview_player
Показать описание
📚 Learn how to solve problems and build projects with these Free E-Books ⬇️

Experience the power of practical learning, gain career-ready skills, and start building real applications!
This is a step-by-step course designed to take you from beginner to expert in no time!
💰 Here is a coupon to save 10% on your first payment (CODEBEAUTY_YT10).
Use it quickly, because it will be available for a limited time.

I use it to enhance the performance, features, and support for C, C#, and C++ development in Visual Studio.
It is a powerful, secure text editor designed specifically for programmers.

A queue is a FIFO Data structure (First in-First out). It is also known as FCFS (First come-First served)
A real-life example of a queue is a queue in a bank - the person who is at the front of the queue will be served first, and the new people who come into the bank will stand at the end of the queue and they will be served last. this means that we add new elements at the end of the queue and we remove them from the front.

We use queues in programming whenever we need things to happen in the exact order they were called, but the computer cannot keep up with the speed and execute those things fast enough.
In this situation, we put those things in a queue and we process/remove them from the front and add new things at the end of the queue.
The most common example of how queues are used in programming is the way a printer works - you can send multiple pages to print, but because printer takes a few seconds to print each page, all pages will be in a queue waiting for their turn to be printed, and they will be printed in the exact order they were sent to print.

I'm also going to share some examples of how I use queues in my programming work, and I'll explain the code of STL Queue and teach you about the most important functions used with queues:
push - add an element at the end
pop - remove an element from the front
size - tells you the size of the queue
front - first element of the queue
back - the last element of the queue
empty - tells you if the queue is empty

However, please don't feel obligated to do so. I appreciate every one of you, and I will continue to share valuable content with you regardless of whether you choose to support me in this way. Thank you for being part of the Code Beauty community! ❤️😇

Contents:
00:00 - What will you learn in this video
02:02 - What is a Queue, What is FIFO/FCFS
02:50 - When to use a queue in programming
05:40 - C++ code for STL Queue explained
08:39 - Solve this programming task and get a shoutout in my next video 📣

Tag me on you Instagram stories:
Рекомендации по теме
Комментарии
Автор

📚 Learn how to solve problems and build projects with these Free E-Books ⬇️
Experience the power of practical learning, gain career-ready skills, and start building real applications!
This is a step-by-step course designed to take you from beginner to expert in no time!
💰 Here is a coupon to save 10% on your first payment (CODEBEAUTY_YT10).
Use it quickly, because it will be available for a limited time.

#include <iostream>
#include<queue>
using namespace std;

void printQueue(queue<int> queue) {

while (!queue.empty())
{
cout << queue.front() << " ";
queue.pop();
}
cout << endl;
}

int main()
{
queue<int> myQueue;
myQueue.push(1);
myQueue.push(2);
myQueue.push(3);

cout << "Size is " << myQueue.size() << endl;
cout << "First element is " << myQueue.front() << endl;
cout << "Last element is " << myQueue.back() << endl;

cout << "My queue: " << endl;
printQueue(myQueue);

system("pause>0");
}

CodeBeauty
Автор

I've been a c++ programmer for 20 years
Your teaching style is great, I recommend it to beginners.

aliustun
Автор

Many programmers upload good tutorials, but asume that some points are just self-explanatory.
You produce excellent videos, but most importantly, you are an outstanding teacher. Thank you.

TheConstantijn
Автор

Saldina we need more your wonderful data structure videos .

volleyballcenter
Автор

Hey Saldina! How are you? Just here to tell you that your videos taught me more than what I learned in the entire semester of Data Structures and Algorithms course at my university.
I can now see that what I lacked was application-oriented thinking. I was just blindly strolling through these ideas and never got the point of "why the heck" would anybody (or I) get to use them...
As always as I would like to be proven wrong, you (your explanations) have been what I needed! Just a nudge in the direction of what and why we use what programmers came up with. I cannot express how immensely gratified I am that finally someone has shown what I longed to get my hands on for quite a while. Thank you is all I can say for now, and if we ever happen to cross paths, I'll make sure to buy you a coffee 😄.
Your admirer,

mjshastry
Автор

Simplicity is also a hard skill to excel! Amazing content Saldina!
Hats off to you!

iampranshu
Автор

Studiram tehnicku informatiku u austriji. Uz tvoju pomoc sam prosao ispite na fakultetu. Jako sam ti zahvalan! Pozdrav is Austrije od Banjalucanina :D

thetruth
Автор

i’ve been reviewing/preparing for data structures with your videos and they’re amazing ! after watching them it clicks ! also like how you tell us why we would use them thank you!

tierasmith
Автор

your lectures are great! Learned pf, oop, and dsa in c++ from you

Hamza-dwiw
Автор

Your English is better than mine. Thank you for the C++ tutorials.

shoshanamofaz
Автор

I found your YouTube videos pretty helpful and prolific. Especially the ones about C++, I request you to post content regarding Assembly Language (preferably x84), it will be a huge favor.

muhammadumair
Автор

amazing explaining and beginner friendly, and english accent is understandable keep your videos they are pretty helpful !

yegho
Автор

Saldina you are the best.
Thanks for your helping tutorial videos.

abdulazizabubakar
Автор

You are the best! Thanks for your videos!!

leonardoguzman
Автор

Super interesting and another informative, instructive video.
Thanks for sharing 👩‍🎓👩‍💻

georgebentley-ricardo
Автор

I like so much your videos. You are a very good teacher. Congrats

edvil
Автор

Hey Saldina, love your videos! Could you please cover trees, graphs, etc. as well? Thanks in advance!

rally
Автор

God bless your soul!!! U r so good at explaining stuff u r the best :, )

priscilapadilla
Автор

Best teacher ever
Keep it up👍🏾👍🏾👌🏾👌🏾👌🏾

eyob
Автор

Hi Saldina,

It gives me great pleasure to watch your videos. I have only started with C++.
As a hobby programmer I started with Visual Basic. In the meantime I prefer to use C#.

I have a general question about C++. I read a lot about RUST replacing C++.

What is your opinion

onkelwaldgeist