Support the stack operations push

124 views 8:09 am 0 Comments August 5, 2023

support the stack operations push, pop, and top, and a new operation findMin, which returns the smallest element in the ExtendedStack, ALL in O(1) worst-case time. Note that findMin returns the minimum value in the extended stack, but do NOT remove it from the structure. , you must type the implementation of ExtendedStack as specified below (C++ code). Your ExtendedStack can wrap (can be composed of) other ADTS and thus reuse their operatons. you can wrap at most 2 structures (choose from: Stack, Queue, and list); you can select any combination: two queues, a stack and a queue, two stacks, … Hint: Besides reuse, the purpose of wraping other strucutes in the ExtendedStack is to achieve a O(1) running time for the findMin() operation. If you are using a structure (e.g. Stack s), you do NOT have to implement the structure. just invoke its standard operations (e.g. s.pop(x)).

Tags: , , , , , , , , , , ,