[TIL] Hey, Queue. Give my one more punch in your face

Captainjack·2021년 4월 16일
0

TIL

목록 보기
21/260

I'm gonna kill this Queue this is my last battle and last chance in my life.

okay let's start then

Queue (Array Implementaion)

this basic shape of the Queue is have Head, Tail, and queue table.

if you wanna enqueueing value '1'

firstly tail indicate the 0 table(default) and then put 1 in number 0 Queue

and then keep doing this I wanna add 2, 3

though, tail indicate 2 of Queue table the tail value is bring the value of index of queue

So now tail got 3(indicate address 2)

and If you wanna Dequeue.
Dequeue isn't a choice something what you wanna delete
It always delete first value and now Head got a first value.

last round

then you wanna put 8 in this situation

it's not put in first value in the queue and gonna start in tail

Queue (Linked List Implementaion)

linked list is head indicate the first value.

tail is also indicated the first value

but if you keep push some value then

this result interesting
the head indicated first value
and tail is move to the new value

so now I see the head only go to the first value.

and tail keep move to the last value.

dequeue is head cut the original line
and it's move to the next value.
tail isn't move when dequeue is working

profile
til' CTF WIN

0개의 댓글