Question: Perform a Big (O) analysis of the overloaded + function for bag. Explain your analysis. bag operator +(const bag& b1, const bag& b2) { bag

Perform a Big (O) analysis of the overloaded + function for bag. Explain your analysis.

bag operator +(const bag& b1, const bag& b2)

{

bag answer;

answer += b1;

answer += b2;

return answer;

}

Given:

void bag::operator +=(const bag& addend)

// Library facilities used: cstdlib, node1.h

{

node *copy_head_ptr;

node *copy_tail_ptr;

if (addend.many_nodes > 0)

{

list_copy(addend.head_ptr, copy_head_ptr, copy_tail_ptr);

copy_tail_ptr->set_link( head_ptr );

head_ptr = copy_head_ptr;

many_nodes += addend.many_nodes;

}

}

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!