Question: # This function will check to see if two stacks contain the same content (not necessarily same order) # It will not permanently modify either

 # This function will check to see if two stacks contain

# This function will check to see if two stacks contain the same content (not necessarily same order) # It will not permanently modify either stack. def func_two(stack1, stack2): if stack1.get_size() is not stack2.get_size(): return False

result = True arr1 = [] arr2 = [] arr1_sorted = [] arr2_sorted = [] while stack1.get_size() > 0: temp1 = stack1.pop() arr1.append(temp1) arr1_sorted.append(temp1) temp2 = stack2.pop() arr2.append(temp2) arr2_sorted.append(temp2) # For item in tmp1, check if item is in tmp2 # If there is a mismatch (item not in tmp2), we want to return false, BUT first return data # Otherwise continue until all items analyzed. Return data.

Whatever is commented out is what I need to do, and this is the code I have so far. Anything helps

In python please

2) A function to determine if two input stacks contain the same elements. The function must not permanently modify the stack, nor can you use direct access to the array containing the data. You may NOT say stack1.stack or stack2.stack and directly access the array. Your solution must utilize the pop method of the stack to interact with any datapoint within them. (You may utilize structures other than a stack inside the solution)

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 Databases Questions!