stack
a = new T[SIZE]
i = 0
push(T x):
if i == a.length():
resize()
a[i++] = x
T pop():
if i == 0:
throw "empty"
return a[--i]
resize():
anew = new[a.length() * 2] //overflow possible
for j=0 to <a.length():
anew[j] = a[j]
a = anew
No comments:
Post a Comment