Question: Given the Linked List Implementation of a Stack ( reference Node * top, is available for use ) , write pseudocode that will determine which

Given the Linked List Implementation of a Stack (reference Node* top, is available
for use), write pseudocode that will determine which value in the stack is the smallest and remove and
return that value while otherwise leaving the remainder of the stack in its original order.
Thus, if the stack1 contains values:
(bottom 468325 top)
then a call to findAndRemoveSmallest(stack1) would return the value 8 and leave stack1 as follows:
(bottom 46835 top)
In your solution, you may only declare extra Stack or primitive variables (e.g. ints, doubles not arrays or
linked lists) if needed.
You can assume that any Stack you use will never become full and that the provided stack will not contain duplicate values.
Rather than throwing an exception, if the provided stack is empty findAndRemoveSmallest () will print an error message..
Write your pseudocode for findAndRemoveSmallest ().

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!