DSA - Queue Flashcards
what is DS
way to store and organize data
is Queue linear DS
yea queue is linear data str
is queue abstract DS
yes, queue is an abstract DS
what is FIFO
first in first out
what are operation on queue
enqueue, dequeue
what is enqueue
inserting node from rear end is known as enquque
what is dequeue
deleting node from front end part is known as dequeue
what are front and rear
front and rear are two variables
what does front part is used for
front part is used for deleting operation
what is use of rear variable
we use rear variable to add data into the queue
from which node we can insert data
we can insert data from rear end
from which part we can delete data in queue
we can delete data from front part in queue
suppose there are three variables, 2, 3, 4 where would front and rear point
front will point to 2 and
rear will point to 4, end of queue
suppose there are three variables, 2, 3, 4 and now you want to insert data into queue, from where will you insert it
we can insert data into queue from rear end, which is pointing to last element
whats the first step when inserting / enqueing element into queue
first we increment the variable, rear++
insert data => second step
what is LILO
LILO is last in last out
do we have to pass parameter into enqueue()
yes we have to pass data, we are inserting into enqueue() function
do we have to pass anything into dequeue() function
no we dont have to pass anython into dequeue()
why we dont pass anything into dequeue()
by default the element is getting deleted is from front part
what is front() or peek() function
it gives us first element without deleting the element
isFull()
this function will return true if queue is empty, else it will return false
isEmpty()
if queue is empty this function will return true, else this function will return false
for which values we initialize front and rear
we initialize front and rear to -1
which variable we increment while doing enqueue()
we increment rear variable while insert elements
which variable stays at the same position while inserting element to queue
front stays at its place while incrementing
what happens when we dequeue an element
we increment the value value of front
peek() returns what
peek() function returns position where front is pointintg
when front and rear become equal
when there is only one element, then the front and rear points to the same position
what is meaning of
#define n 5
define N, makes global variable and add 5 to it
what is first thing we check into enqueue() function
first thing we check in enqueue() function, is that is queue is overflow or not
overflow means, is queue is full or not
what are applications of queue
serving request from single source
in OS processes are placed into queue