Exam 1 Sample Questions
for (int i = 0; i < n ; i ++){
for (int j=0; j < n; j++){
loop body
}
}
Answer: T_n = cn^2
Assume instance variables
int length;
int maxSize;
someType thisStack[] = new thisStack[maxSize];
retType pop(){
if (length() == 0)
underflow_error()
else{
return thisStack[length--];
}
}