other approach is:
1. Add 0 to the array if it is odd
2. Sort the array
3. Now swap the second element and second last element.
4. In this way keep swapping every second element from front with every
second element from back.
5. Stop when front pointer is greater than back.
6. Sum the first half and second half.

Time Complexity: O(nlogn)
No extra space needed.

On Sun, May 8, 2011 at 8:53 AM, MANNU <manishkr2...@gmail.com> wrote:

> Steps to follow:
> 1.Sort the given array.
> 2.Partition each consecutive element in 2 arrays i.e. if 1st element is in
> 1st array then second will be 2nd array and 3rd in 1st.
>
>
> But for equal no. of elements you have to check for no. of elements in the
> array. If they are odd either insert a dummy elemnt
> of value 0 else output an error message (whatever you feel better).
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Gaurav Aggarwal
SCJP

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to