Semi-infinite: Difference between revisions

From formulasearchengine
Jump to navigation Jump to search
en>R'n'B
 
Line 1: Line 1:
<br><br>Obtaining the most helpful and best hunting knife is crucial and so you have to make certain that excellent steps are taken to get hold of the proper a single. It is also possible to get lots of diverse knives for your various reasons and so you have to know how to get the ideal a single that would serve your goal. You require to make confident that excellent endeavours are made to ensure that you deal with to get the characteristics for your use. A excellent supply would aid you to get the perfect that enables you decide on from a wide selection of diverse knives for you. <br>Hi there, my title is Jeff Maron and I build customized knives. My experience with the outdoor,hunting and fishing as properly as carrying out taxidermy has given me the knowledge with knives to know what kind of knife is needed to perform a good quality job. I build substantial top quality fastened blade knives as properly as folders. My knives are constructed to be used however they are strikingly desirable. I build a personalized knife for cutting the wedding cake that can be used as a substantial high quality chef's knife. All my knives contain a hand stitched leather sheath.<br>This plot line creates a amazing planet reminiscent of Venetian trading electricity in opposition to the withdrawn eastern empire some have in comparison it to a roman republic, which is nonsense - because the Roman's had an army, their electrical power wasn't grown initially out of trade and the Vesani were anti-expansion, the romans had been [http://www.thebestpocketknifereviews.com/best-swiss-army-knife-choosing-the-best-models/ swiss army knife Tools] not, and whilst this is remarkable globe constructing the author does not focus upon it at all - which helps make it all that significantly much more impressive. Tents need to have screens and windows as these enable you to see the outdoors of your tent and guard yourselves from bugs and other animals in the wild.<br>Several hunters set a lot of thought into the blade style of their looking knife, but set quite minor thought into the substance of the take care of. The basic wood, bone, or leather handles are extremely useful and desirable to the eye. Nonetheless, do not forget the newer manage resources, though not as pleasing to the eye, rubber and other composites benefit a search. The more recent handle components offer you tremendously increased control in adverse situations giving the hunter a increased diploma of protection. If you are looking for for extended survival, then you are suggested to get a multi-purpose blade that evidently implies that the blade is a element straight edge.<br>The Gerber Gator 154 CM will come from a lengthy line of extremely powerful Gerber Gator knives. Gerber originally unveiled the Gerber Gator I and then adopted with the Gerber Gator II. The Gerber Gator 154 CM is the Ferrari of the Gerber Gator knives. Very first the knife blade is produced from 154CM stainless steel which is a higher quality blade. The folding system makes it possible for for very relaxed handing of the knife as effectively as the usefulness of portability which can be the difficulty over other bulkier knives. The Gerber Gator sequence is nicely recognized for it is non-slip take care of grips. <br>A patch knife during the 18th century carried by the lengthy hunter, trapper, mountain gentleman or frontiersman could be stated as extended as you could cut a good patch for your prolonged gun it was regarded as a patch knife. Most generally this was a smaller sized to medium sized knife with no distinct blade design and style. I've reviewed several of their multitools and identified them all to be exceptional items of package that are deserving of being in your pack, and I've even provided a couple of their fantastic goods away. So, you know that I was eager to get my fingers on one of their new knives in their Survival Sequence<br>I adore this knife a lot! I disagree with people who mentioned the blade isn't very good. I have created two extremely strong forts currently with this awesome knife. If any a single is taking into consideration getting this knife they need to. The great design and style and well structured build of it is superb. Bear Grylls and Gerber did an outstanding occupation on this properly crafted knife. Very first of all, I love your merchandise. You happen to be like the” Glock” of cutlery. You [http://sss.chaoslab.ru/tracker/mim_plugs/newticket?reporter=anonymous&summary=AttributeError%3A+%27Environment%27+object+has+no+attribute+%27get_db_cnx%27&description=%0D%0A%0D%0AAn+excellent+app+from+AppBox+Professional+that+is+actually+a+swiss+army+knife+to+your+Apple+Iphone.+This+app+comes+equipped+with+a+chock+stuffed+with+utilities+and+tools+that+can+be+utilized+for+on+a+regular+basis+things.+Essentially%2C+this+app+can+do+the+whole+lot+that+20+apps+do+multi+functional.+Comes+with+a+inbuilt+safe+pockets+to+safe+all+of+your+vital+infomaton+comparable+to+credit+card+information%2C+checking+account+information%2C+memberships%2C+etc.+There%27s+additionally+a+flashlight%2C+calculator%2C+alarm+and+a+lot+extra.+Just+a+should+get+app%21%0D%0A%0D%0AThat%27s+why%2C+for+me%2C+the+Tinker+offers+a+good+compromise.+What+is+the+best+Swiss+Army+Knife+for+you%3F+The+combinations+can+get+a+little+complicated.+Here+are+some+favorite+models.+What+Swiss+Army+Knife+design+fits+your+personality%2C+sparse+and+light%2C+heavy+duty%2C+or+a+compromise%3F+The+bottom+line+is+that+you%27re+going+to+be+able+to+get+at+things+better+with+the+proper+tools+and+if+you+carry+a+Swiss+Army+knife+or+multi-tool%2C+chances+are+you+will+have+the+right+tool+with+you.+Are+you+looking+for+a+Swiss+Army+Knife+that%27s+compact+enough+to+be+unnoticeable+when+you+carry+it+in+your+pocket%2C+or+maybe+the+perfect+knife+to+attach+to+a+key+chain%3F+Victorinox+-+Swiss+Army+40251+Slicer+Knife+w%2F+14-in+Granton+Blade%2C+Rosewood+Handle+knives+but+rare+on+chef%27s+knives.%0D%0A%0D%0AThe+Paramilitary+2+is+regarded+by+many+in+the+community+as+Spyderco%27s+finest+folding+knife.+It+achieves+close+to+perfection+for+a+top+quality%2C+robust+use+EDC+knife.+The+Para+2+is+considerably+massive+%28+8.2%E2%80%B3+inches+when+opened+with+a+three.4%E2%80%B3+blade+%29+but+very+lightweight+for+its+size+%28+3.75+ounces+%29.+The+blade+is+created+from+the+extremely+fashionable+S30V+metal+with+a+full+flat+grind.+The+blade%2C+like+most+Spyderco+knives%2C+comes+hair+shaving+sharp+right+from+the+manufacturing+facility%2C+and+being+such+a+high+quality+steel+will+hold+this+edge+sharpness+for+longer+durations+of+time+during+typical+use.%0D%0A%0D%0AIt+ought+to+be+noted+that+the+final+alternative+for+any+multi-software%2C+folding%2C+or+EDC+knife+ought+to+rely+heavily+upon+the+varieties+of+features+you+know+will+likely+be+required+or+ones+you+anticipate+might+be+needed+for+specific+tasks.+By+no+means+base+the+ultimate+choice+merely+on+the+aesthetic+appeal+of+a+knife.+Doing+the+correct+research+and+due+diligence+will+enable+you+to+decide+on+the+perfect+pocket+knife+that+is+applicable+to+your+own+personal+preferences+and+on+daily+basis+cutting+wants.+Numerous+individuals+from+many+parts+of+the+world+use+pocket+knives+for+an+abundant+quantity+of+jobs.+They+won%27t+leave+home+with+out+one.%0D%0A%0D%0AThe+other+useful+thing+about+a+good+travel+knife+is+that+should+the+worst+come+to+the+worst+you+can+use+it+as+a+self+defence+tool%2C+though+my+recommendation+if+you+are+caught+in+a+dark+alley%2C+is+to+hand+over+whatever+the+crooks+demand+%2C+but+sometimes+that+just+isn%27t+enough.+Your+travel+knife+may+prove+the+difference+between+life+and+death+in+these+%5Bhttp%3A%2F%2FMondediplo.com%2Fspip.php%3Fpage%3Drecherche%26recherche%3Dextreme%2Bcircumstances+extreme+circumstances%5D.+As+for+its+uses+-+you+are+only+limited+by+your+imagination%21+This+travel+accessory+is+great+for+picnics%2C+perfect+for+minor+repairs+and+even+helpful+for+personal+grooming.+We+always+take+one+on+any+vacation.+They+are+just+that+handy%21+We+really+appreciate+one+when+we+are+hiking%2C+camping+and+of+course+backpacking.+What+Sizes+Do+They+Come+In%3F+DIY+Off-Grid+Projects+For+This+Summer+-+July+17%2C+2014%0D%0A%0D%0AMost+of+the+Swiss+Army+fashions+have+knife+blades+fabricated+from+ratherthin+inventory.+They%27re+sharpened+evenly+on+each+side+at+a+laser+verified+15-degreeangle.+When+shipped+from+the+manufacturing+facility%2C+Swiss+Army+Knives+are+sharp+and+the+edgeis+simply+maintained.+I+use+a+positive+Arkansas+stone+on+all+of+my+Swiss+ArmyKnives+to+touch+up+the+edge%2C+while+avoiding+undue+blade+wear.+The+standard+bladeshape+makes+use+of+a+drop+point+with+a+comparatively+long%2C+straight+leading+edge+thatcurves+gently+to+a+nearly+symmetrical%2C+spade+formed%2C+point+at+roughly+themid-blade+stage.+Wenger+calls+this+a+%22spear+blade.%22+It+is+a+utility+shape%2C+not+a+fighting+blade.%0D%0A%0D%0APlato+once+mentioned+that+individuals+are+like+filth.+They+can+nourish+you+or+stunt+your+progress.+This+appears+sage+and+reasonable%2C+but+I+feel+individuals+are+extra+like+Swiss+Military+knives+%28To+be+honest%2C+Plato+did+not+benefit+from+knowing+of+such+a+tool%2C+so+I+do+not+think+I+am+detracting+from+his+comparability+in+the+least%29.+Swiss+Military+knives%2C+as+we+all+know%2C+are+extremely+versatile%2C+and+have+a+tool+for+nearly+any+situation.+Need+to+open+a+bundle%E2%80%94it%27s+received+a+knife%21+Sharing+beers+with+pals+on+the+beach%E2%80%94it%27s+obtained+an+opener%21+Have+something+in+your+teeth%E2%80%94there%27s+a+toothpick+for+that%21%0D%0A%0D%0AThat%27s+why+it+really+jumped+out+at+me+when+I+came+across+this%C2%A0knife.+It%27s+actually+hard+to+call+it+a+knife+%E2%80%93+it%27s+kind+of+a+full-on+compact+system+of+survival+and+elf+workshop%C2%A0tools%2C+all+in+one.+I+saw+it+and+curiosity+took+a+hold+of+me+like+Carla%27s+dad+one+day+when+he+came+home+early+and+thought+we+were+in+school.+I+was+pleasantly+surprised.%C2%A0Not+about+Carla%27s+dad+%E2%80%93+he+wasn%27t+so+pleasant+that+day.+The+knife+impressed+me+though.+The+Victorinox+may+cost+only+%2440%2C+but+it+packs+some+serious+features+for+the+price.+First+and+foremost%2C+it%27s+made+of+X50CrMoV15+In+most+categories+it%27s+difficult+to+find+reviews+of+budget-oriented+gear%2C+but+apparently+knives+are+the+exception.+The+Victorinox+stood+out+as+the+knife+to+beat.++If+you+loved+this+article+and+you+want+to+receive+much+more+information+about+%5Bhttp%3A%2F%2FWww.Thebestpocketknifereviews.com%2Fbest-swiss-army-knife-choosing-the-best-models%2F+swiss+army+pocket+knife%5D+please+visit+our+page.+Who+else+likes+it%3F&create=Create guys generate] some of the best bladed items in the marketplace. I enjoy this knife! My mom acquired if for me for Xmas and I have it often! Many thanks mother! And many thanks Bear Grylls.<br>A congress knife Elephant's toenail The elephant's toenail is massive design and style comparable to the sunfish but normally tapers on one particular stop offering it the "elephant's toenail" condition. These knives like the sunfish generally have two extensive blades Peanut The peanut knife is a very little knife with a single or two blades. Penknife The penknife was at first [http://www.thebestpocketknifereviews.com/best-swiss-army-knife-choosing-the-best-models/ Best swiss army knives] meant to sharpen quill pens , but proceeds to be employed since of its suitability to fine or sensitive function. A pen knife typically has a single or two pen blades, and does not interfere with the look of dress outfits when carried in the pocket.<br>The Pace Protected technological innovation is made up of a torsionbar that retains the knife shut. To deploy the blade you have to utilize manual pressurein a thumb stud or in a protrusion that sticks out at the back again of the blade toovercome the resistance of the torsion bar. Once that the blade is out of the handlethe torsion bar takes over and deploy the knife effortlessly. They get in touch with it SpeedSafe since the torsion bar stops that the knife opens in its personal by incident. One more option for a patch knife in early America was the folding knife. This knife as properly could be carried in a looking pouch, pocket, or attainable bag.<br>A good survival knife can have many employs, these kinds of as slicing tree limbs, which can be used for splints for broken arms. You can use it as a pry bar or digging tool. Slicing strips of vine to tie a raft jointly or a shelter. Making a fishing spear from a straight piece of wood. But what makes a survival knife practical in the outside or even in a existence-and -demise circumstance. Buck Elk Take care of Folding Hunter Knife with B&C Medallion is a single of the ideal-offering available in the market place today, you can find it easily in on the web and offline shop. You can also compare this merchandise in Ebay.
{{Infobox Algorithm
|class=[[Sorting algorithm]]
|image=[[File:Insertion Sorting during proxmap.PNG|none|315px|Insertion sorting into buckets during proxmap.]]
|caption=Example of insertion sort sorting a list of random numbers.
|data=[[Array data structure|Array]]
|time=<math>O(n^2)</math>
|best-time=<math>O(n)</math>
|space=<math>O(n)</math>
}}
[[Image:Bucket sort 1.png|right|frame|Elements are distributed among bins]]
[[Image:Bucket sort 2.png|right|frame|Unlike bucket sorting which sorts after all the buckets are filled, the elements are [[insertion sort]]ed as they are inserted]]
'''ProxmapSort''', or '''Proxmap sort''', is a [[sorting algorithm]] that works by partitioning an [[Array data structure|array]] of data items, or keys, into a number of "subarrays" (termed [[bucket (computing)|bucket]]s, in similar sorts). The name is short for computing a "proximity map," which indicates for each key K the beginning of a subarray where K will reside in the final sorted order. Keys are placed into each subarray using [[insertion sort]]. If keys are "well distributed" among the subarrays, sorting occurs in linear time, much faster than [[comparison sort|comparison-based]] sorting, which can do no better than <math>O(n \log n)</math>. The [[computational complexity]] estimates involve the number of subarrays and the proximity mapping function, the "map key," used. It is a form of [[bucket sort|bucket]] and [[radix sort]]. The algorithm scales up well as the number of data become large.
 
Once a ProxmapSort is complete, '''ProxmapSearch''' can be used to find keys in the sorted array in <math>O(1)</math> time if the keys were well distributed during the sort.
 
==History==
* Invented in the late 1980s by [http://www.ics.uci.edu/faculty/profiles/view_faculty.php?ucinetid=standish Thomas A. Standish], Prof. Emeritus, Department of Informatics, [[Donald Bren School of Information and Computer Sciences]], University of California, Irvine.
 
==Overview==
===Basic strategy===
 
In general:
Given an array '''A''' with ''n'' keys:
* map a key to a subarray of the destination array '''A2''', by applying the map key function to each array item
* determine how many keys will map to the same subarray, using an array of '''"hit counts," H'''
* determine where each subarray will begin in the destination array so that each bucket is exactly the right size to hold all the keys that will map to it, using an array of '''"proxmaps," P'''
* for each key, compute the subarray it will map to, using an array of '''"locations," L'''
* for each key, look up its location, place it into that cell of '''A2'''; if it collides with a key already in that position, insertion sort the key into place, moving keys greater than this key to the right by one to make a space for this key. Since the subarray is big enough to hold all the keys mapped to it, such movement will never cause the keys to overflow into the following subarray.
 
Simplied version:
Given an array '''A''' with ''n'' keys
# '''Initialize''': Create and initialize 2 arrays of ''n'' size: '''hitCount''', '''proxMap''', and 2 arrays of '''A'''.length: '''location''', and '''A2'''.
# '''Partition''': Using a carefully chosen '''mapKey''' function, divide the '''A2''' into subarrays using the keys in '''A'''
# '''Disperse''': Read over '''A''', dropping each key into its bucket in '''A2'''; insertion sorting as needed.
# '''Collect''': Visit the subarrays in order and put all the elements back into the original array, or simply use '''A2'''.
 
Note: "keys" may also contain other data, for instance an array of Student objects that contain the key plus a student ID and name. This makes ProxMapSort suitable for organizing groups of objects, not just keys themselves.
 
===Example===
 
Consider a full array: '''A'''[''0'' to ''n-1''] with ''n'' keys. Let ''i'' be an index of A. Sort '''A''''s keys into array '''A2''' of equal size.
 
The map key function is defined as mapKey(key) = floor(K).
 
{| class="wikitable" style="text-align: center; width: 400px; border: 1px solid black;"
|+ Array table
|-
! scope="row" | A1
| 6.7 || 5.9 || 8.4 || 1.2 || 7.3 || 3.7 || 11.5 || 1.1 || 4.8 || 0.4 || 10.5 || 6.1 || 1.8
|-
! scope="row" | H
| 1 || 3 || 0 || 1 || 1 || 1 || 2 || 1 || 1 || 0 || 1 || 1
|-
! scope="row" | P
| 0 || 1 || -9 || 4 || 5 || 6 || 7 || 9 || 10 || -9 || 11 || 12
|-
! scope="row" | L
| 7 || 6 || 10 || 1 || 9 || 4 || 12 || 1 || 5 || 0 || 11 || 7 || 1
|-
! scope="row" | A2
| 0.4 || 1.1 || 1.2 || 1.8 || 3.7 || 4.8 || 5.9 || 6.1 || 6.7 || 7.3 || 8.4 || 10.5 || 11.5
|}
[[File:ProxMapSortDemo.gif|A demonstration of ProxMapSort, a bucket sort variant that uses intermediate parallel arrays to efficiently index and size its sublists.]]
<br clear=all>
===Pseudocode===
<source lang="java">
// compute hit counts
for i = 0 to 11 // where 11 is n
{
    H[i] = 0;
}
for i = 0 to 12 // where 12 is A.length
{
    pos = MapKey(A[i]);
    H[pos] = H[pos] + 1;
}
 
runningTotal = 0; // compute prox map – location of start of each subarray
for i = 0 to 11
    if H[i] = 0
        P[i] = -9;
    else
        P[i] = runningTotal;
        runningTotal = runningTotal + H[i];
 
for i = 0 to 12 // compute location – subarray – in A2 into which each item in A is to be placed
    L[i] = P[MapKey(A[i])];
 
for I = 0 to 12; // sort items
    A2[I] = <empty>;
for i = 0 to 12 // insert each item into subarray beginning at start, preserving order
{
    start = L[i]; // subarray for this item begins at this location
    insertion made = false;
    for j = start to (<the end of A2 is found, and insertion not made>)
    {
        if A2[j] == <empty> // if subarray empty, just put item in first position of subarray
            A2[j] = A[i];
            insertion made = true;
        else if A[i] < A2[j] // key belongs at A2[j]
            int end = j + 1; // find end of used part of subarray – where first <empty> is
            while (A2[end] != <empty>)
                end++;
            for k = end -1 to j // move larger keys to the right 1 cell
                A2[k+1] = A2[k];
                A2[j] = A[i];
            insertion made = true; // add in new key
    }
}
</source>
 
Here '''A''' is the array to be sorted and the mapKey functions determines the number of subarrays to use. For example, floor(K) will simply assign as many subarrays as there are integers from the data in '''A'''. Dividing the key by a constant reduces the number of subarrays; different functions can be used to translate the range of elements in '''A''' to subarrays, such as converting the letters A–Z to 0–25 or returning the first character (0–255) for sorting strings. Subarrays are sorted as the data comes in, not after all data has been placed into the subarray, as is typical in [[bucket sorting]].
 
==Proxmap Searching==
ProxmapSearch uses the '''proxMap''' array generated by a previously done ProxmapSort to find keys in the sorted array '''A2''' in constant time.
 
===Basic strategy===
*Sort the keys using ProxmapSort, keeping  the'''MapKey''' function, and the '''P''' and '''A2''' arrays
*To search for a key, go to P[MapKey(k)], the start of the subarray that contains the key, if that key is in the data set
*Sequentially search the subarray; if the key  is found, return it (and associated information); if find a value greater than the key, the key is not in the data set
*Computing P[MapKey(k)] takes <math>O(1)</math> time. If a map key that gives a good distribution of keys was used during the sort, each subarray is bounded above by a constant ''c'', so at most ''c'' comparisons are needed to find the key or know it is not present; therefore ProxmapSearch is <math>O(1)</math>. If the worst map key was used, all keys are in the same subarray, so ProxmapSearch, in this worst case, will require <math>O(n)</math> comparisons.
 
===Pseudocode===
 
'''function''' mapKey(key)
  '''return''' floor(key)
 
  proxMap ← previously generated proxmap array of size n
  A2 ← previously sorted array of size n
'''function''' proxmap-search(key)
  '''for''' i = proxMap[mapKey(key)] '''to''' length(array)-1
    '''if''' (sortedArray[i].key == key)
      '''return''' sortedArray[i]
 
==Analysis==
===Performance===
Computing H, P, and L all take <math>O(n)</math> time. Each is computed with one pass through an array, with constant time spent at each array location.
*Worst case: MapKey places all items into one subarray, resulting in a standard insertion sort, and time of <math>O(n^2)</math>.
*Best case: MapKey delivers the same small number of items to each subarray in an order where the best case of insertion sort occurs. Each insertion sort is <math>O(c)</math>, ''c'' the size of the subarrays; there are ''p'' subarrays thus '''p * c = n''', so the insertion phase take O(n); thus, ProxmapSort is <math>O(n)</math>.
*Average case: Each subarray is at most size ''c'', a constant; insertion sort for each subarray is then O(c^2) at worst – a constant. (The actual time can be much better, since c items are not sorted until the last item is placed in the bucket). Total time is the number of buckets, '''(n/c)''', times <math>O(c^2)</math> = <math>O(n)</math>.
 
Having a good MapKey function is imperative for avoiding the worst case. We must know something about the distribution of the data to come up with a good key.
 
===Optimizations===
# Save time: Save the MapKey(i) values so they don't have to be recomputed (as they are in the code above)
# Save space: The proxMaps can be stored in the hitCount array,as the hit counts are not needed once the proxmap is computed; the data can be sorted back into A, instead of using A2, if one takes care to note which A values are have been sorted so far, and which not.
 
===Comparison with other sorting algorithms===
Since ProxmapSort is not a [[comparison sort]], the Ω(''n'' log ''n'') lower bound is inapplicable. Its speed can be attributed to it not being comparison-based and using arrays instead of dynamically allocated objects and pointers that must be followed, such as is done with when using a [[binary search tree]].
 
ProxmapSort allows for the use of ProxmapSearch. Despite the O(n) build time, ProxMapSearch makes up for it with its <math>O(1)</math> average access time, making it very appealing for large databases. If the data doesn't need to be updated often, the access time may make this function more favorable than other [[non-comparison sorting]] based sorts.
 
===Generic bucket sort related to ProxmapSort===
Like ProxmapSort, bucket sort generally operates on a list of ''n'' numeric inputs between zero and some maximum key or value ''M'' and divides the value range into ''n'' buckets each of size ''M''/''n''. If each bucket is sorted using [[insertion sort]], ProxmapSort and bucket sort can be shown to run in predicted linear time.<ref>[[Thomas H. Cormen]], [[Charles E. Leiserson]], [[Ronald L. Rivest]], and [[Clifford Stein]]. ''[[Introduction to Algorithms]]'', Second Edition. MIT Press and McGraw-Hill, 2001. ISBN 0-262-03293-7. Section 8.4: Bucket sort, pp.174&ndash;177.</ref> However, the performance of this sort degrades with clustering (or too few buckets with too many keys); if many values occur close together, they will all fall into a single bucket and performance will be severely diminished. This behavior also holds for ProxmapSort: if the buckets are too large, its performance will degrade severely.
 
==References==
<references />
* Thomas A. Standish. ''Data Structures in Java.'' Addison Wesley Longman, 1998. ISBN 0-201-30564-X. Section 10.6, pp.&nbsp;394&ndash;405.
 
* Thomas A. Standish and Norman Jacobson [http://portal.acm.org/ft_gateway.cfm?id=1138427&type=pdf "Using O(n) ProxmapSort and O(1) ProxmapSearch to Motivate CS2 Students (Part I)"] from [[Donald Bren School of Information and Computer Sciences]] at [[University of California, Irvine|UC Irvine]].
 
* Thomas A. Standish and Norman Jacobson [http://portal.acm.org/citation.cfm?id=1138403.1138427 "Using O(n) ProxmapSort and O(1) ProxmapSearch to Motivate CS2 Students (Part II)"] from [[Donald Bren School of Information and Computer Sciences]] at [[University of California, Irvine|UC Irvine]].
 
* Norman Jacobson [http://www.ics.uci.edu/~jacobson/ics23/ProxmapHandout.pdf "A Synopsis of ProxmapSort & ProxmapSearch"] from Department of Computer Science, [[Donald Bren School of Information and Computer Sciences]], [[University of California, Irvine|UC Irvine]].
 
==External links==
* http://www.cs.uah.edu/~rcoleman/CS221/Sorting/ProxMapSort.html
* http://www.valdosta.edu/~sfares/cs330/cs3410.a.sorting.1998.fa.html
* http://www.cs.uml.edu/~giam/91.102/Demos/ProxMapSort/ProxMapSort.c
 
{{sorting}}
 
{{DEFAULTSORT:ProxmapSort}}
[[Category:Sorting algorithms]]
[[Category:Stable sorts]]
[[Category:Articles with example pseudocode]]

Revision as of 08:45, 28 September 2012

Template:Infobox Algorithm

Elements are distributed among bins
Unlike bucket sorting which sorts after all the buckets are filled, the elements are insertion sorted as they are inserted

ProxmapSort, or Proxmap sort, is a sorting algorithm that works by partitioning an array of data items, or keys, into a number of "subarrays" (termed buckets, in similar sorts). The name is short for computing a "proximity map," which indicates for each key K the beginning of a subarray where K will reside in the final sorted order. Keys are placed into each subarray using insertion sort. If keys are "well distributed" among the subarrays, sorting occurs in linear time, much faster than comparison-based sorting, which can do no better than . The computational complexity estimates involve the number of subarrays and the proximity mapping function, the "map key," used. It is a form of bucket and radix sort. The algorithm scales up well as the number of data become large.

Once a ProxmapSort is complete, ProxmapSearch can be used to find keys in the sorted array in time if the keys were well distributed during the sort.

History

Overview

Basic strategy

In general: Given an array A with n keys:

  • map a key to a subarray of the destination array A2, by applying the map key function to each array item
  • determine how many keys will map to the same subarray, using an array of "hit counts," H
  • determine where each subarray will begin in the destination array so that each bucket is exactly the right size to hold all the keys that will map to it, using an array of "proxmaps," P
  • for each key, compute the subarray it will map to, using an array of "locations," L
  • for each key, look up its location, place it into that cell of A2; if it collides with a key already in that position, insertion sort the key into place, moving keys greater than this key to the right by one to make a space for this key. Since the subarray is big enough to hold all the keys mapped to it, such movement will never cause the keys to overflow into the following subarray.

Simplied version: Given an array A with n keys

  1. Initialize: Create and initialize 2 arrays of n size: hitCount, proxMap, and 2 arrays of A.length: location, and A2.
  2. Partition: Using a carefully chosen mapKey function, divide the A2 into subarrays using the keys in A
  3. Disperse: Read over A, dropping each key into its bucket in A2; insertion sorting as needed.
  4. Collect: Visit the subarrays in order and put all the elements back into the original array, or simply use A2.

Note: "keys" may also contain other data, for instance an array of Student objects that contain the key plus a student ID and name. This makes ProxMapSort suitable for organizing groups of objects, not just keys themselves.

Example

Consider a full array: A[0 to n-1] with n keys. Let i be an index of A. Sort A's keys into array A2 of equal size.

The map key function is defined as mapKey(key) = floor(K).

Array table
A1 6.7 5.9 8.4 1.2 7.3 3.7 11.5 1.1 4.8 0.4 10.5 6.1 1.8
H 1 3 0 1 1 1 2 1 1 0 1 1
P 0 1 -9 4 5 6 7 9 10 -9 11 12
L 7 6 10 1 9 4 12 1 5 0 11 7 1
A2 0.4 1.1 1.2 1.8 3.7 4.8 5.9 6.1 6.7 7.3 8.4 10.5 11.5

A demonstration of ProxMapSort, a bucket sort variant that uses intermediate parallel arrays to efficiently index and size its sublists.

Pseudocode

// compute hit counts
for i = 0 to 11 // where 11 is n
{
    H[i] = 0;
}
for i = 0 to 12 // where 12 is A.length
{
    pos = MapKey(A[i]);
    H[pos] = H[pos] + 1;
}

runningTotal = 0; // compute prox map – location of start of each subarray
for i = 0 to 11
    if H[i] = 0
        P[i] = -9;
    else
        P[i] = runningTotal;
        runningTotal = runningTotal + H[i];

for i = 0 to 12 // compute location – subarray – in A2 into which each item in A is to be placed
    L[i] = P[MapKey(A[i])];

for I = 0 to 12; // sort items
    A2[I] = <empty>;
for i = 0 to 12 // insert each item into subarray beginning at start, preserving order
{
    start = L[i]; // subarray for this item begins at this location
    insertion made = false;
    for j = start to (<the end of A2 is found, and insertion not made>)
    {
        if A2[j] == <empty> // if subarray empty, just put item in first position of subarray
            A2[j] = A[i];
            insertion made = true;
        else if A[i] < A2[j] // key belongs at A2[j]
            int end = j + 1; // find end of used part of subarray – where first <empty> is
            while (A2[end] != <empty>)
                end++;
            for k = end -1 to j // move larger keys to the right 1 cell
                A2[k+1] = A2[k];
                A2[j] = A[i];
            insertion made = true; // add in new key
    }
}

Here A is the array to be sorted and the mapKey functions determines the number of subarrays to use. For example, floor(K) will simply assign as many subarrays as there are integers from the data in A. Dividing the key by a constant reduces the number of subarrays; different functions can be used to translate the range of elements in A to subarrays, such as converting the letters A–Z to 0–25 or returning the first character (0–255) for sorting strings. Subarrays are sorted as the data comes in, not after all data has been placed into the subarray, as is typical in bucket sorting.

Proxmap Searching

ProxmapSearch uses the proxMap array generated by a previously done ProxmapSort to find keys in the sorted array A2 in constant time.

Basic strategy

  • Sort the keys using ProxmapSort, keeping theMapKey function, and the P and A2 arrays
  • To search for a key, go to P[MapKey(k)], the start of the subarray that contains the key, if that key is in the data set
  • Sequentially search the subarray; if the key is found, return it (and associated information); if find a value greater than the key, the key is not in the data set
  • Computing P[MapKey(k)] takes time. If a map key that gives a good distribution of keys was used during the sort, each subarray is bounded above by a constant c, so at most c comparisons are needed to find the key or know it is not present; therefore ProxmapSearch is . If the worst map key was used, all keys are in the same subarray, so ProxmapSearch, in this worst case, will require comparisons.

Pseudocode

function mapKey(key)
  return floor(key)
  proxMap ← previously generated proxmap array of size n
  A2 ← previously sorted array of size n
function proxmap-search(key)
  for i = proxMap[mapKey(key)] to length(array)-1
    if (sortedArray[i].key == key)
      return sortedArray[i]

Analysis

Performance

Computing H, P, and L all take time. Each is computed with one pass through an array, with constant time spent at each array location.

  • Worst case: MapKey places all items into one subarray, resulting in a standard insertion sort, and time of .
  • Best case: MapKey delivers the same small number of items to each subarray in an order where the best case of insertion sort occurs. Each insertion sort is , c the size of the subarrays; there are p subarrays thus p * c = n, so the insertion phase take O(n); thus, ProxmapSort is .
  • Average case: Each subarray is at most size c, a constant; insertion sort for each subarray is then O(c^2) at worst – a constant. (The actual time can be much better, since c items are not sorted until the last item is placed in the bucket). Total time is the number of buckets, (n/c), times = .

Having a good MapKey function is imperative for avoiding the worst case. We must know something about the distribution of the data to come up with a good key.

Optimizations

  1. Save time: Save the MapKey(i) values so they don't have to be recomputed (as they are in the code above)
  2. Save space: The proxMaps can be stored in the hitCount array,as the hit counts are not needed once the proxmap is computed; the data can be sorted back into A, instead of using A2, if one takes care to note which A values are have been sorted so far, and which not.

Comparison with other sorting algorithms

Since ProxmapSort is not a comparison sort, the Ω(n log n) lower bound is inapplicable. Its speed can be attributed to it not being comparison-based and using arrays instead of dynamically allocated objects and pointers that must be followed, such as is done with when using a binary search tree.

ProxmapSort allows for the use of ProxmapSearch. Despite the O(n) build time, ProxMapSearch makes up for it with its average access time, making it very appealing for large databases. If the data doesn't need to be updated often, the access time may make this function more favorable than other non-comparison sorting based sorts.

Generic bucket sort related to ProxmapSort

Like ProxmapSort, bucket sort generally operates on a list of n numeric inputs between zero and some maximum key or value M and divides the value range into n buckets each of size M/n. If each bucket is sorted using insertion sort, ProxmapSort and bucket sort can be shown to run in predicted linear time.[1] However, the performance of this sort degrades with clustering (or too few buckets with too many keys); if many values occur close together, they will all fall into a single bucket and performance will be severely diminished. This behavior also holds for ProxmapSort: if the buckets are too large, its performance will degrade severely.

References

  1. Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. Introduction to Algorithms, Second Edition. MIT Press and McGraw-Hill, 2001. ISBN 0-262-03293-7. Section 8.4: Bucket sort, pp.174–177.
  • Thomas A. Standish. Data Structures in Java. Addison Wesley Longman, 1998. ISBN 0-201-30564-X. Section 10.6, pp. 394–405.

External links

Template:Sorting