Consider the following statements:
S1 : Implementation of stack using queue, deletion of second element from top of stack time complexity Ο(n), when insertion take Ο(1) time.
S2 : In implementation of queue using stack, deletion of second element from front take Ο(1) time, when insertion take Ο(n) time.
Both the statements are true. HOW? Kindly provide a detailed explanation. I am unable to solve such questions.
In implementation of stack using queue or queue using stack, only one operation can be O(1) and the other has to be O(n).
Check these links