Write a function with three parameters. The first parameter is a head pointer fo
ID: 3560615 • Letter: W
Question
Write a function with three parameters. The first parameter is a head pointer for a linked list of items, and the next two parameters are x and y. The function should write to the screen all items in the list that are between the first occurrence of x and the first occurrence of y. You may assume that items can be compared for equality using ==.
Explanation / Answer
void list_head_insert(node*& head_ptr, const node::value_type& entry) { head_ptr = new node(entry, head_ptr); } void list_insert(node* previous_ptr, const node::value_type& entry) { node *insert_ptr; insert_ptr = new node(entry, previous_ptr->link( )); previous_ptr->set_link(insert_ptr); } void getItems(const node* head_ptr, const node::value_type& x, const node::value_type& y) { bool isvalid = false; while (head_ptr != NULL) { if(head_ptr->data() == x) { isvalid = true; } if(isvalid == true) { cout data() == y) { isvalid = false; } } }Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.