Worksheetssingle linked list
Total questions: 2
Worksheet time: 4mins
What is the functionality of the following code?public void function(Node node)
{
if(size == 0)
head = node;
else
{
Node temp,cur;
for(cur = head; (temp = cur.getNext())!=null; cur = temp);
cur.setNext(node);
}
size++;
}
Inserting a node at the beginning of the list
Deleting a node at the beginning of the list
Inserting a node at the end of the list
Deleting a node at the end of the list
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;
}
Find and return the position of the given element in the list
Find and delete a given element in the list
Find and return the given element in the list
Find and insert a new element in the list
