Question: The function h ( ) takes a pointer to the front of a non - empty singly linked list and a list position pos, 0

The function h() takes a pointer to the front of a non-empty singly linked list
and a list position pos, 0<= pos < n, where n is the number of elements in the linked list.
template
void h(node * & front, int pos)
{
node *p,*q;
p = front;
if (pos ==0)
{
front = front->next;
delete p;
}
else
{
for (int i =1; i < pos; i++)
p = p->next;
q = p->next;
p->next = q->next;
delete q;
}
}
Assume the list contains the elements
front -->45->10->5->15->20->31
Display the elements in the list after two consecutive calls to h().
h(front,1);
front -->___________________________________________________________________
h(front,0);
front -->___________________________________________________________________

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!