Share
Explore BrainMass

basic, stack, data, structure

1. Let us say you are given a basic stack data structure with just "core" operations push and pop. Is it possible to implement top using these two operations? Explain. (or) Are the following code segments equivalent? Why?

x = s.top();

x = s.pop();
s.push(x);

Solution Preview

Yes, they are equivalent. pop() removes the object at the top of this stack and returns that object ...

Solution Summary

This job notes basic stack data structure.

$2.19