Question: 2. (10 points) Write the pseudo code for function node list_search(node* head_ptr, const node::value_type& target); where head_ptr is the head pointer of a linked list.

 2. (10 points) Write the pseudo code for function node list_search(node*

2. (10 points) Write the pseudo code for function node list_search(node* head_ptr, const node::value_type& target); where head_ptr is the head pointer of a linked list. The function returns a pointer to the first node containing the specified target in its data field. If there is no such node, the null pointer is returned. You can also use C+code as you prefer. 3. (10 points) The following code defines the overloading assignment operator "-" for bag class with a linked list. What will happen if we do a self-assignment with this code, e.g., b -b (b is an object of class bag)? If the result is inaccurate, find if anything is missed. void bag: :operator -(const bag& source) node tail_ptr; I/ Needed for argument to list_copy list_clear (head_ptr); many_nodes0 list_copy(source.head_ptr, head_ptr, tail_ptr) many_nodessource.many_nodes; Here, many_nodes is a private member in the bag class to record the number of nodes in the list. You can also find both precondition and postcondition of list_clear and list_copy in our textbook (page 256) 2. (10 points) Write the pseudo code for function node list_search(node* head_ptr, const node::value_type& target); where head_ptr is the head pointer of a linked list. The function returns a pointer to the first node containing the specified target in its data field. If there is no such node, the null pointer is returned. You can also use C+code as you prefer. 3. (10 points) The following code defines the overloading assignment operator "-" for bag class with a linked list. What will happen if we do a self-assignment with this code, e.g., b -b (b is an object of class bag)? If the result is inaccurate, find if anything is missed. void bag: :operator -(const bag& source) node tail_ptr; I/ Needed for argument to list_copy list_clear (head_ptr); many_nodes0 list_copy(source.head_ptr, head_ptr, tail_ptr) many_nodessource.many_nodes; Here, many_nodes is a private member in the bag class to record the number of nodes in the list. You can also find both precondition and postcondition of list_clear and list_copy in our textbook (page 256)

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!