Making the push operation costly, select the code snippet which implements the pop operation.
A.
public void pop()
{
if(q1.size()>0)
{
q2.poll();
}
else if(q2.size()>0)
{
q1.poll();
}
}B.
public void pop()
{
if(q1.size()>0)
{
q1.poll();
}
else if(q2.size()>0)
{
q2.poll();
}
}C.
public void pop()
{
q1.poll();
q2.poll();
}D.
public void pop()
{
if(q2.size()>0)
{
q1.poll();
}
else
{
q2.poll();
}
}Answer: Option B
Related Questions on Introduction to Data Structures
A. A collection of data values
B. A programming language
C. A set of algorithms
D. A way of organizing and storing data

Join The Discussion