What is a Stack ADT ?
It is linear data structure where there is one element and another element and then another element.
Behavior of the Stack ADT :
It is a list which is flexible with its size.
A stack is what would be called a LIFO data structure, last in first out.
It’s much like an actual stack of plates. The last plate you put on top of that stack, that’s going to be the first one you remove, its LIFO, last in first out.
Operations on Stack include :
isempty() – Checks if the stack is empty (Returns True/False)
isfull() – Checks if the stack is full (Returns True/False)
push() – Pushes the element into the stack
pop()- Removes the element from the list
What is a Queue ADT ?
It is linear data structure and works on FIFO( first in first out).
Behaviour of the Stack ADT :
It has a Restriction of performing insertion at one end and deletion at the opposite end.?
It is flexible with its size.
Operations on Queue include :
enqueue() – Inserts the element,
dequeue() – Deletes the element and returns it.
isempty() – Checks if the queue is empty (Returns True/False)
isfull() – Checks if the queue is full (Returns True/False)
Differences between a non-circular queue and a circular queue :
A non-circular queue is in the form of a line where elements are queued behind each other, it has ends
A circular queue is in the form of a circle. Last and first element are connected , it has no ends.
Non-circular queue works on FIFO. Insertion and deletion must be in a sequential order.
Circular queue does not have any order of insertion and deletion.It can be done from any position.
Vacancy must be created in-order to insert an element in non circular queue.
Simultaneous insertion and deletion can be done in circular queue.
Diagrams :
https://d2vlcm61l7u1fs.cloudfront.net/media%2Faf2%2Faf2d93c3-4dde-4dde-8d3e-d11778a59975%2FphpFeFgsq.png
?
Pseudocode :
?Queue: isfull(A)
isfull(A)
if rear(A) = length(A)
then x = 1
else x = rear(A) + 1
if x = front(A)
then return True
else return False
Queue:isempty(A)
isempty(A)
if front(A) = rear(A)
then return True
else return False
Queue: enqueue(A, x)
Enqueue(A,n)
if isfull(A)
then error “Queue is full”
else A[rear(A)] = x
if rear(A) = length(A)
then rear(A) = 1
else rear(A) = rear(A) + 1
Queue: dequeue(A)
Dequeue(A)
if isempty(A)
then error “Queue is empty”
else x = A[front(A)]
if front(A) = length(A)
then front(A) = 1
else front(A) = front(A) + 1
return x
Why does each operation except enqueue(A, x) only require the single argument A?
Ans)
Dequeue() removes the element from the front which only requires the list as argument?.
isfull() and isempty() returns true or false values which only requires the list as argument
While enqueue() should specify the element as well as the the list so it has two arguments.
“Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!”
What Students Are Saying About Us
.......... Customer ID: 12*** | Rating: ⭐⭐⭐⭐⭐"Honestly, I was afraid to send my paper to you, but splendidwritings.com proved they are a trustworthy service. My essay was done in less than a day, and I received a brilliant piece. I didn’t even believe it was my essay at first 🙂 Great job, thank you!"
.......... Customer ID: 14***| Rating: ⭐⭐⭐⭐⭐
"The company has some nice prices and good content. I ordered a term paper here and got a very good one. I'll keep ordering from this website."