the last element of the linked list will be deleted when pos is greater than the length of the list so whatrs the use of if(prev==NULL)