implement this function using a doubly linked list instead of single linked list
ID: 3529124 • Letter: I
Question
implement this function using a doubly linked list instead of single linked list, the function takes in 3 parameters, a head pointer and 2 values. the function displays the numbers between the two values.
void display(const node* head_ptr, const node::value_type x, const node::value_type y)
{
if(head_ptr != NULL)
{
const node *cursor;
for(cursor = head_ptr; cursor!= NULL; cursor = cursor ->link())
{
if(cursor->data() == y)
{
cursor = cursor->link();
cout<<"Number List" << endl;
while((cursor->data() !=x))
{
cout << cursor->data() << endl;
cursor = cursor->link();
}
cout << endl << endl;
}
}
}
}
Explanation / Answer
Please rate with 5 stars :)
http://www.thelearningpoint.net/computer-science/lists/c-program-source-code-with-documentation-for-a-doubly-linked-list
This clearly explains all the functions which correspond to the conversion of a singly linked list to a doubly linked list.
Cheers!
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.