Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2014 Administration

Authors: Adam Jorgensen, Bradley Ball

1st Edition

111885926X, 9781118859261

More Books

Students also viewed these Databases questions