Question

In: Computer Science

•Use commented pseudo-code to describe a process for each of the following: 1)Assigning a shopper to...

•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

Solutions

Expert Solution

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


Related Solutions

Use pseudo code to plan a programming solution for the following: A GUI interface to ensure...
Use pseudo code to plan a programming solution for the following: A GUI interface to ensure a user is old enough to play a game. See additional resources above for additional resources. Properly formatted prompts to input name, address, phone number, and age. Instructions to ensure that the information is displayed back to the user. Also, the user must be 21. So, include instructions to display an appropriate message about whether or not the user can continue. Instructions that will...
The Case of the Coding Dilemma Background: Coding is the process of assigning a billing code...
The Case of the Coding Dilemma Background: Coding is the process of assigning a billing code to a patient diagnosis. The billing code comes from a standardized code book. Each code represents a specific diagnosis and a designated amount of reimbursement by government and private insurers. Entering a higher code than is warranted will result in overpayment for the patient’s particular diagnosis. Entering a lower code than is warranted will result in underpayment for the patient’s particular diagnosis. All diagnoses...
Write pseudo-code to solve the following problem using MapReduce and explain how it works. Each line...
Write pseudo-code to solve the following problem using MapReduce and explain how it works. Each line in the file lists a user ID, the ID of the movie the user watched, the rating the user gave for the movie, and the timestamp. For example line 1 indicates that the user’s ID is 196, the movie ID is 242, the user gave this movie a rating of 3, and the timestamp is 881250949. Given the file, find out the top similar...
Submit a document with methods for an automobile class, and pseudo code indicating functionality of each...
Submit a document with methods for an automobile class, and pseudo code indicating functionality of each method. Example: public String RemoveVehicle(String autoMake, String autoModel, String autoColor, int autoYear) If values entered match values stored in private variables remove vehicle information else return message indicating mismatch
Write a MATLAB code to obtain the following. Keep your code commented whenever required. Copy your...
Write a MATLAB code to obtain the following. Keep your code commented whenever required. Copy your source code and command widow outcomes and screen shots of any plots in your solution. Develop three functions for temperature-conversion. Create a function called F_to_K that converts and return temperatures in Fahrenheit to Kelvin and store results in ‘F_to_K2.txt’. Create a function called C_to_R that converts and return temperatures in Celsius to Rankine and store results in ‘C_to_R2.txt’. Create a function called C_to_F that...
Write a MATLAB code to obtain the following. Keep your code commented whenever required. Copy your...
Write a MATLAB code to obtain the following. Keep your code commented whenever required. Copy your source code and command widow outcomes and screen shots of any plots in your solution. Write a user defined function ‘My_FunctionGen’. It accepts, the time vector ‘t’ with 8000 uniformly spaced values within the range of 0 to 8, Frequecy scalars ‘f1<100H’ and ‘f2<80Hz’ and Amplitude scalars ‘A1’, ‘A2’ and ‘A3’ as input arguments. It delivers x1, x2 and x3 and x4 as outputs...
Write a MATLAB code to obtain the following. Keep your code commented whenever required. Copy your...
Write a MATLAB code to obtain the following. Keep your code commented whenever required. Copy your source code and command widow outcomes and screen shots of any plots in your solution. Generate the following vectors and also implement the Table-1 operations-map by employing the switch statement and an appropriate loop. Generate a vector ‘DEC1’ as follow. DEC1 = 5     1     3     0     2    5     0     2 Concatenate vector ‘DEC1’ eight times in order to obtain a bigger row vector ‘DEC’...
Write a MATLAB code to obtain the following. Keep your code commented whenever required. Copy your...
Write a MATLAB code to obtain the following. Keep your code commented whenever required. Copy your source code and command widow outcomes and screen shots of any plots in your solution. Develop three functions for temperature-conversion. Create a function called F_to_K that converts and return temperatures in Fahrenheit to Kelvin and store results in ‘F_to_K2.txt’. Create a function called C_to_R that converts and return temperatures in Celsius to Rankine and store results in ‘C_to_R2.txt’. Create a function called C_to_F that...
Describe in pseudo-code, a linear-time algorithm for reversing a queue Q. To access the queue, you...
Describe in pseudo-code, a linear-time algorithm for reversing a queue Q. To access the queue, you are only allowed to use the basic functions of the queue ADT defined as follows (Hint: Using a stack, the basic stack functions defined in the textbook and in the class). class Queue { public: int size(); bool isEmpty(); Object front(); void enqueue(Object o); Object dequeue(); };
Develop the pseudo code for, desk check and test the following programs. Allow the user to...
Develop the pseudo code for, desk check and test the following programs. Allow the user to provide the number of elements, and initialise the array according to their input. Use functions where appropriate to ensure modularity. 1. Find the average of a list of numbers 2. Find the smallest element in a list of numbers
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT