O(1)
O(n)
O(log n)
O(n^2)
Question 12
template
void linkedStackType
{
nodeType
if(stackTop!=NULL)
{
temp=stackTop;
stackTop=stackTop->link;
delete temp;
}
else
cerr<<"ERROR"<
}
push
pop
top
copy
Question 13
template
void linkedStackType
{
nodeType
if(stackTop!=NULL)
{
temp=stackTop;
stackTop=stackTop->link;
delete temp;
}
else
cerr<<"ERROR"<
}
The stack is full
The stack is empty
The element does not exist
The stack is nonempty but not full
stackTop
stackTop - 1
0
-1
Question 15
#include
#include "myStack.h"
using namespace std;
int main()
{
stackType
stackType
intStack.push(18);
intStack.push(21);
intStack.push(25);
tempStack = intStack;
while(!tempStack.isEmptyStack())
{
cout<
tempStack.pop();
}
cout<
cout<
return 0;
}
18
21
25
50
Question 16
template
Type stackType
{
assert(stackTop != 0);
return list[stackTop - 1];
}
top
pop
push
isEmptyStack
Two
Three
Four
Five
num
count
sizeOf
size
modulation
comparison
analysis
simulation
operations
lists
customers
servers
