Peter Cordes
0
Q:

what is time complexity of swap function

The Behaviour is Equivalent to: 

template <class T> void swap ( T& a, T& b )
{
  T c(a); a=b; b=c;
}

Syntax : Swap(a,b) // a = Number 1 , b = Number 2

Time Complexity: It makes one constructions and one assignments
				 So, Linear O(n) time.
1

New to Communities?

Join the community