Examveda

What is the functionality of the following piece of code?
public int function(int data)
{
	Node temp = head;
	int var = 0;
	while(temp != null)
	{
		if(temp.getData() == data)
		{
			return var;
		}
		var = var+1;
		temp = temp.getNext();
	}
	return Integer.MIN_VALUE;
}

A. Find and delete a given element in the list

B. Find and return the given element in the list

C. Find and return the position of the given element in the list

D. Find and insert a new element in the list

Answer: Option C


This Question Belongs to Data Structure >> Introduction To Data Structures

Join The Discussion

Related Questions on Introduction to Data Structures