In: Computer Science
•Use commented pseudo-code to describe a process for each of the following:
1)Assigning a shopper to one of several checkout lines based on:
•the number of shoppers already in each line, and
•the number of items in the shopper’s cart, and
•the type of items (e.g., “Food”, “Clothing”, “Housewares”, etc.)
2)Assigning a new student into the correct desk in a room of students seated in alphabetical order
•Design classes (attributes and methods) for the following data structures:
4)Stack
5)Queue
Pseudo Code for stacks -
// Function to push data into the stack
Push(S,x)
// check if stack is full, if yes then stack overflow problem occurs
if Stack-Full(S)
then error "overflow"
// if stack is not full then add the element on the top most poition
else top(S) = top(S) + 1
S[top(S)] = x
// function to remove data from the stack
Pop(S)
// check if stack is empty, if yes then stack underflow problem occurs
if Stack-Empty(S)
then error "underflow"
// if stack is not empty then decrease the top index by -1, this removes the element on top of the stack
else top(S) = top(S) - 1
return S[top(S) + 1]
// function to check whether the stack is empty or not
Stack-Empty(S)
if top(S) = 0
then return True
else return False
// function to check whether the stack is full or not
Stack-Full(S)
if top(S) = length(S)
then return True
else return False
// Driver Code
Driver()
Stack S
// Add element to the stack
Push(S, 4)
// Add element to the stack
Push(S, 3)
// Add element to the stack
Push(S, 2)
// Remove the element from the stack
Pop(S)
// Remove the element from the stack
Pop(S
Psuedo code for Queue -
InsertIntoQueue(Q,x)
// Check if queue is full or not, if full then overflow problem occurs
if Queue-Full(Q)
then error "overflow"
else Q[tail(Q)] = x
// if queue is not full then add the element at the end of the queue
if tail(Q) = length(Q)
then tail(Q) = 1
else tail(Q) = tail(Q) + 1
RemoveFromQueue(Q)
// Check if queue is empty or not, if empty then underflow problem occurs
if Queue-Empty(Q)
then error "underflow"
else x = Q[head(Q)]
// if queue is not empty then remove the first
// element by increasing the FIRST index by 1 such that it now points to the second element
if head(Q) = length(Q)
then head(Q) = 1
else head(Q) = head(Q) + 1
return x
// Function to check if queue is full or not
Queue-Full(Q)
if tail(Q) = length(Q)
then n = 1
else n = tail(Q) + 1
if n = head(Q)
then return True
else return False
// Function to check if queue is empty or not
Queue-Empty(Q)
if head(Q) = tail(Q)
then return True
else return False
Kindly like and upvote for my effort