About the first exercise. Most of you have implemented a standard stack. The main difficulty of the exercise was to get operations to execute at constant time. Let's leave aside push and pop operations for now, and let's focus on getMin().
If getMin() has to iterate the whole structure every time it is called, then its execution time will always depend on the size of the structure. Since there is no restriction on memory, an idea could be to add a field holding the current minimum to the structure. Therefore, our structure would contain an array of items, plus an int called min.
This could work, but what if the min is popped from the list. Then we would have to store an array of minimums. Since pop and push are the only ways of adding or removing data, we could ensure the integrity of our minimum array.
Here's the solution I have implemented. It's written in C and uses linked lists instead of arrays. You should simply focus on the implementation of push, pop and getMin operations in rhm_struct.c
linkedlist.h
rhm_struct.h
linkedlist.c
rhm_struct.c
main.c
Now note that this solution is not complete. Are we sure that pop() and push() are not iterating the structure? This issue is actually a bit more complicated. I'll leave you to solve it :-)