On Mon, Jul 11, 2011 at 1:51 AM, aanchal goyal <[email protected]>wrote:
> These are the various ways to swap 2 variables
> a) Using temporary Variable
>
always inefficient. using extra memory.
> b) Usnig some Arithmentic operation
>
works for all numbers even floating points
a and b are two no. to swap : a=a+b;
b=a-b;
a=a-b;
always works
> c) Using bitwise XOR operation
>
since bitwise results an error in floating point numbers so this method
also fails.
hence (b) is better among the three.what say ?
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
--
best wishes!!
Vaibhav Shukla
DU-MCA
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.