The follow code contains two constructors for a user created Stack Data Structure.
public class ArrayStack<T> implements BoundedStackInterface<T> {
protected T[] stack;
public final int defCap = 100;
public ArrayStack() {
stack = (T[]) new Object[defCap];
}
}
public class ArrayStack<T> implements BoundedStackInterface<T> {
protected T[] stack;
public ArrayStack(int maxSize) {
stack = (T[]) new Object[maxSize];
}
}
Now in my book the Big(O) of these two constructors is stated to be O(N) but our instructor tried to tell us they should be O(1).
Would someone mind explaining to me why it is O(N) and not O(1)?