Back in the early 90's, I had a need to do depth-first and breadth-first searches on some data. These algorithms are relatively simple with recursion; not so much in iterative languages like RPG or COBOL. Wound up developing a way to use an array to simulate a stack, and came up with an iterative algorithm.
Anyway, at the time I didn't know about data queues. A *LIFO data queue *is* a stack. Push and Pop are simply QDNDDTAQ and QRCVDTAQ. Even without recursion, using a data queue for the stack might have made for simpler code than what I came up with. Faster is debatable, but definitely simpler.
Anyway, at the time I didn't know about data queues. A *LIFO data queue *is* a stack. Push and Pop are simply QDNDDTAQ and QRCVDTAQ. Even without recursion, using a data queue for the stack might have made for simpler code than what I came up with. Faster is debatable, but definitely simpler.
Comment