adplus-dvertising
frame-decoration

Question

What is the functionality of the following piece of code?
public void function(Object item)
{
	Node temp=new Node(item,trail);
	if(isEmpty())
	{
		head.setNext(temp);
		temp.setNext(trail);
	}
	else
	{
		Node cur=head.getNext();
		while(cur.getNext()!=trail)
		{
			cur=cur.getNext();
		}
		cur.setNext(temp);
	}
	size++;
}

a.

Insert at the front end of the dequeue

b.

Insert at the rear end of the dequeue

c.

Fetch the element at the rear end of the dequeue

d.

Fetch the element at the front end of the dequeue

Answer: (b).Insert at the rear end of the dequeue

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the functionality of the following piece of code?