Aug 20, 2013 at 9:39pm
Would you mind posting your custom class linkedStackType definition?
What methods/functions are available to be called?
Aug 21, 2013 at 7:04am
Yes kevin is right.
I would imagine this will be implemented in terms of a recursive function. Something like this:
1 2 3 4 5 6 7 8 9 10 11 12 13
|
typedef linkedStackType stack;
template <typename Type>
bool isEqual(stack<Type> &stack1, stack<Type> &stack2) {
Type lh, rh;
int ret = 0;
if ( (lh = stack1.pop()) == (rh = stack2.pop()) ) {
if ( !stack1.isEmptyStack() and !stack2.isEmptyStack() ) return isEqual(stack1, stack2);
else ret = 1;
}
stack1.push(lh);
stack2.push(rh);
return ret;
}
|
Last edited on Aug 21, 2013 at 7:05am