Question: You are given the implementation of a method - transfer(S,T) - as follows: static void transfer(Stack S, Stack T) { while (!S.isEmpty()) { T.push(S.pop()); }

You are given the implementation of a method - transfer(S,T) - as follows:

static void transfer(Stack S, Stack T) { while (!S.isEmpty()) { T.push(S.pop()); } }

What does this function do ?

A. Transfers all elements from stack S onto stack T , so that the element at the top of S is the rst to be inserted onto T , and the element at the bottom of S ends up at the top of T

B. Transfers all elements from stack S onto stack T, so that the element that starts at the top of S is the last to be inserted onto T , and the element at the bottom of S ends up at the bottom of T

C. Is equivalent to T=S

D. The code will throw error

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!