sort, hash or pars
i have been reading about sorting algorithums and have a basic question. it seems the terms sort, hash and pars are used interchageably. what is the difference as far as implementation? all of these techniques seem to do pretty much the same thing,
do they just go about it a different way?
here's my 2 cents worth:
sorts use a physical attribute intrinsic to an item to place them in some sort of order----alphabetically in reverse based on value of 2 char of last name or whatever. To search for a given item you have to look at each item in turn, although on average you only have to search half the collection once they are in order.
hash takes some intrinsic attribute and places it in some sort of formula using the result to place the item in "order". The difference is now you can search faster for a given item by using the same formula in the search as for the sort. On average, unless you have a large number of items hashing to the same spot (collisions), you have to search far fewer items in a collection that has been hashed than on a collection that has been sorted. A good hashing function to use will vary depending on the collection. A good hashing function will produce few collisions so searching should be faster than even with a sorted collection.
pars to me means breaking up into pieces based on some criteria. For example, parsing a sentence into individual words or parsing the word Mississippi using each i as the pars symbol.
Thanks Guest, now let me ask a bit more specific question,
take a 2 dimensional array
column 0 contains an identification
column 1 contains a valie related to the identification:
this array wil contain about 1500 rows.
column 0 column 1
to sort by column 1 which would be the best algorithum.