Difference between pages "3.5" and "4.3"

From The Algorithm Design Manual Solution Wiki
(Difference between pages)
Jump to navigation Jump to search
 
(Created page with "<pre> Algo - If we create pair of (min1, max2n) (min1, max2n-1)... will provide optimal result 1) Sort the set of 2n element (n log n) 2) Now assign two pointers Start: A[...")
 
Line 1: Line 1:
1. size 4 array with 3 elements. remove 1, insert 1, and so forth. <br>
+
<pre>
2. when the array is one-fourth full, shrink its size to half of what it was.
+
Algo -
 +
If we create pair of (min1, max2n) (min1, max2n-1)... will provide optimal result
 +
1) Sort the set of 2n element (n log n)
 +
2) Now assign two pointers
 +
  Start: A[0]
 +
  End:  A[2n-1]
 +
  while (start < end)
 +
      pair(start, end)
 +
      start++
 +
      end--
 +
  EndLoop
 +
</pre>
 +
--[[User:Max|Max]] 06:55, 25 June 2010 (EDT)
  
  
Back to [[Chapter 3]]
+
Back to [[Chapter 4]]

Latest revision as of 18:20, 20 September 2020

Algo -
If we create pair of (min1, max2n) (min1, max2n-1)... will provide optimal result
1) Sort the set of 2n element (n log n)
2) Now assign two pointers 
   Start: A[0]
   End:   A[2n-1]
   while (start < end)
      pair(start, end)
      start++
      end--
   EndLoop

--Max 06:55, 25 June 2010 (EDT)


Back to Chapter 4