Answered step by step
Verified Expert Solution
Question
1 Approved Answer
begin{tabular}{l|c|} hline MAKEVECTOR (row) new Vector puzzle(4) puzzle[1] i in [p,4) : q.enqueue(row[i]) for i in [p,4) : row [i]= row[i-p] for i in [0,p)
\begin{tabular}{l|c|} \hline MAKEVECTOR (row) new Vector puzzle(4) puzzle[1] i in [p,4) : q.enqueue(row[i]) for i in [p,4) : row [i]= row[i-p] for i in [0,p) : row[i] = q.dequeue() return row end function \\ \hline \end{tabular} function PERMUTEROWS (puzzle, x,y,z) puzzle[1] PERMUTEVECTOR(puzzle[1], x ) puzzle[2] PERMUTEVECTOR(puzzle[2], y) puzzle[3]PERMUTEVECTOR(puzzle[3], z) We will complete a function called SearchStack(stack, item) that will search a stack for the value item: if item is in one of the elements of the stack, we remove that element storing item. Otherwise, the function should return FALSE Let's demonstrate this with diagram. We have the following stack: We want to look for the value 3 in the stack and remove it if it is there, otherwise if it is not there, return FALSE. The value 3 is stored in the stack so we then need to remove it so the stack could look like this: The next task will be to complete a function that does this process of searching a stack and possibly removing an element. Task 4: Complete the following function: function SearchStack(stack, item) end function This function will take a stack and a value (called item) as input parameters and return FALSE if item is not stored in the stack, otherwise return the stack without the element storing item. [6 marks] Please answer TASK 4 by referring the functions. Please answer in Pseudocode
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started