The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
0 votes
225 views

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 DS by (317 points)
edited by | 225 views
0

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).

https://www.geeksforgeeks.org/implement-stack-using-queue/

https://www.geeksforgeeks.org/queue-using-stacks/

Check these links

Please log in or register to answer this question.

Related questions

+3 votes
1 answer
2
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,309 questions
55,743 answers
192,226 comments
90,495 users