Re: [algogeeks] partitioning the array
still not getting the correct output -- 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.
[algogeeks] partitioning the array
partition the array into 2 parts such that they have equal number of elements and the difference of the sum of the two parts is minimum. -- 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.
Re: [algogeeks] partitioning the array
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.
Re: [algogeeks] partitioning the array
87 100 28 67 68 41 67 1 for this output should be 229 230 -- 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.
Re: [algogeeks] partitioning the array
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.