Question: Create a recursive algorithm that takes two sorted stacks as parameters (max value at the top), and counts the number of the same elements between

Create a recursive algorithm that takes two sorted stacks as parameters (max value at the top), and counts the number of the same elements between the two. For example S1 {2, 3, 4, 5} and S2 {4, 5, 6, 9, 10, 15} should return 2 as both stacks contain 4 and 5.

The stacks remain unaffected after the program is run (i.e they are returned to their original state).

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!