Queue in C# 2022 For Beginner (Step-By-Step Breakdown) Linkedin: / teddy-smith-015ba61a3 Website: www.teddysmith.io Github: github.com/teddysmithdev
Пікірлер: 11
@Kindergarden-fp6eo14 күн бұрын
Thank you for your lesson
@SaitamaTheLegend Жыл бұрын
You forgot to make the enqueue circular. Only the dequeue is circular in your example.
@hymus8627 Жыл бұрын
I have question in Dequeue method when front == maxSize you make front = 0 but what about rear ? rear is still there when we Dequeue all and front start at 0 again we done cant do anything more becuz if I Enqueue more after we dequeue all it error becuz rear is == maxsize if we enqueue more index will out of bound can we reset rear to -1 too ? like this if(front == maxSize) { front = 0; rear = -1; } or it cannot because something ? can you tell me ?
@TasFirinErkegi9 ай бұрын
you can
@candice317211 ай бұрын
Dude if i just learn your playlist do you think i can be job ready ? Obviously i will put effort and practice regularly.
@TasFirinErkegi9 ай бұрын
Doing the job is easy hard part is getting hired.
@ronjohnson1234 ай бұрын
theres alot more to most jobs then just understanding algorithms haha
@mariomandzukic867610 ай бұрын
Man you are teaching ppl wrong in queueue you shoud do front%maxsize and rare%maxsize and so that you can populate empty spaces for instance you have 1-9 first 2 leave and you have first 2 empty spaces and you add 2 more you get exepction you cant put 11 things cuz oyu have 10 max size and with rare+1%maxsize you will populate first 2 spaces since 10%10 =0
@chadgregory90372 жыл бұрын
Dude Bojangles > Chik
@TeddySmithDev2 жыл бұрын
After they took away the cheddar Bo, I just can’t look bojangles the same anymore lol
@kvelez7 ай бұрын
using System; namespace ConsoleApp1 { internal class Program { static void Main(string[] args) { Queue queue = new Queue(6); queue.Enqueue(1); queue.Enqueue(2); queue.Enqueue(3); queue.Enqueue(4); Console.WriteLine(queue.Peek()); Console.WriteLine(queue.IsEmpty()); Console.WriteLine(queue.IsFull()); while (!queue.IsEmpty()) { Console.WriteLine(queue.Dequeue()); } } } public class Queue { public int MaxSize { get; set; } public int[] QueueArray { get; set; } public int Front { get; set; } public int Rear { get; set; } public int ItemPointer { get; set; } public Queue(int size) { MaxSize = size; QueueArray = new int[size]; Front = 0; Rear = -1; ItemPointer = 0; } public void Enqueue(int item) { if (IsFull()) { Console.WriteLine("Queue is full. Cannot enqueue."); return; } Rear = (Rear + 1) % MaxSize; QueueArray[Rear] = item; ItemPointer++; } public int Dequeue() { if (IsEmpty()) { Console.WriteLine("Queue is empty. Cannot dequeue."); return -1; // Return a default value (you can choose another approach) } int temp = QueueArray[Front]; Front = (Front + 1) % MaxSize; ItemPointer--; return temp; } public int Peek() { if (IsEmpty()) { Console.WriteLine("Queue is empty. Cannot peek."); return -1; // Return a default value (you can choose another approach) } return QueueArray[Front]; } public bool IsEmpty() { return ItemPointer == 0; } public bool IsFull() { return ItemPointer == MaxSize; } } }