Example #1
0
 void pop() {
     if(left.empty()) {
         while(!right.empty()) {
             left.push(right.top());
             right.pop();
         }
     }
     left.pop();
 }
Example #2
0
 int top() {
     if(left.empty()) {
         while(!right.empty()) {
             left.push(right.top());
             right.pop();
         }
     }
     return left.top();
 }
Example #3
0
    int min() {
        if(left.empty())
            return right.min();
        if(right.empty())
            return left.min();

        if(left.min() < right.min())
            return left.min();
        else
            return right.min();
    }
Example #4
0
    int max() {
        if(left.empty())
            return right.max();
        if(right.empty())
            return left.max();

        if(left.max() > right.max())
            return left.max();
        else
            return right.max();
    }
Example #5
0
 int empty() {
     if(left.empty() && right.empty())
         return 1;
     else
         return 0;
 }