stack and queue with other provided function check