More algorithms for stacks/arrays