Originally Posted by
Kennedy
Given an array of, say 4096. You think it would be better to use a stack? How would you go about this? Are you speaking of recursion?
A stack might be defined like this:
Code:
struct stack {
int *array,
size,
first_element;
};
Then you have push and pop functions to operate on this. Notice you can shift the first element without moving the array at all and use size-first_element to determine when to wrap around.
More detailed explanation here:
Stack - Array Implementation