11.07.2015 Views

Encyclopedia of Computer Science and Technology

Encyclopedia of Computer Science and Technology

Encyclopedia of Computer Science and Technology

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

448 sound file formatsapproach, <strong>and</strong> it is comparable in speed <strong>and</strong> stability to theheapsort.Hash SortsAll <strong>of</strong> the sorting algorithms discussed so far rely uponsome form <strong>of</strong> comparison. However, it also possible to sortrecords by calculating their relative positions or distribution(see hashing). In its simplest form, an array can becreated whose range <strong>of</strong> indexes is equal to 1 to the maximumpossible key value. Each key is then stored in theindex position equal to its value (that is, a record with a key<strong>of</strong> 2314 would be stored in the array at position Array[2314].This procedure works well, but only if the keys are all integers,the range is small enough to fit in memory, <strong>and</strong> thereare no duplicate keys (since a duplicate would in effectoverwrite the record already stored in that position).A more practical approach is to use a formula (hashfunction) that should create a unique hash value for eachkey. The function must be chosen to minimize “collisions”where two keys end up with the same hash value, whichcreates the same problem as with duplicate keys. A hashsort is quite efficient within those constraints.SearchingOnce one has a database (sorted or not), the next questionis how to search for records in it. As with sorting, thereare a variety <strong>of</strong> approaches to searching. The simplest <strong>and</strong>least efficient is the linear search. Like the selection sort,the linear search simply goes through the database recordssequentially until it finds a matching key or reaches the endwithout a “hit.” If there is indeed a matching record, on theaverage it will be found in half the time needed to processthe whole database.In most real applications the database will have beensorted using one <strong>of</strong> the methods discussed earlier. Here, thebasic approach is to do a binary search. First the key in themiddle record in the database is examined. The key is comparedwith the search key. If the search key is smaller, thenany matching key must be in the first half <strong>of</strong> the database.Otherwise, it must be in the second half (unless, <strong>of</strong> course,it happens to be the matching key). The process is thenrepeated. That is, if the key is somewhere in the first half,that portion <strong>of</strong> the list is in turn split in half <strong>and</strong> its middlevalue is examined, <strong>and</strong> the comparison to the search key ismade. Thus, the area in which the matching key must befound is progressively cut in half until either the matchingkey is found or there are no more records to check. Because<strong>of</strong> the power <strong>of</strong> successive division, the binary search isvery quick, <strong>and</strong> doubling the size <strong>of</strong> the database meansadding only one more comparison on the average.Sometimes knowledge about the distribution <strong>of</strong> keysin the database can be used to improve even the binarysearch. For example, if keys are alphabetical <strong>and</strong> the searchkey begins with S, it is likely to be faster to pick a startingpoint near the end <strong>of</strong> the list rather than from the middle. Abinary tree (see tree) can be constructed from the keys in adatabase in order to analyze the most likely starting pointsfor a search.Finally, hashing (as previously discussed) can be usedto quickly calculate the expected location <strong>of</strong> the desiredrecord, provided there are no collisions.Further ReadingKnuth, Donald E. Art <strong>of</strong> <strong>Computer</strong> Programming, Volume 3: Searching<strong>and</strong> Sorting. 2nd ed. Upper Saddle River, N.J.: Addison-Wesley Pr<strong>of</strong>essional, 1998.Ploedereder, Erhard. “The Sort Algorithm Animator V1.0.” Availableonline. URL: http://www.iste.uni-stuttgart.de/ps/Ploedereder/sorter/sortanimation2.html.Accessed August 21, 2007.Sedgewick, Robert. Algorithms in C++: Parts 1–4: Fundamentals,Data Structures, Sorting, Searching. Upper Saddle River, N.J.:Addison-Wesley, 1998.Wilt, Nicholas. Classical Algorithms in C++: With New Approachesto Sorting, Searching, <strong>and</strong> Selection. New York: Wiley, 1995.sound file formatsThere are a number <strong>of</strong> ways that sound can be sampled,stored, or generated digitally (see music, computer). Herewe will look at some <strong>of</strong> the most popular sound file formats.WAVThe WAV (wave) file format is specific to Micros<strong>of</strong>t Windows.It essentially stores the raw sample data that representsthe digitized audio content, including informationabout the sampling rate (which in turns affects the soundquality). Since WAV files are not compressed, they can consumeconsiderable disk space.AIFFAIFF st<strong>and</strong>s for Audio Interchange File Format, <strong>and</strong> is specificto the Apple Macintosh <strong>and</strong> to Silicon Graphics (SGI)platforms. Like WAV, it stores actual sound sample data. Avariant, AIFF-C, can store compressed sound.AUThe AU (audio) file format was developed by Sun Microsystems<strong>and</strong> is used mainly on UNIX systems, <strong>and</strong> also in Javaprogramming.MIDIMIDI st<strong>and</strong>s for Musical Instrument Digital Interface.Unlike most other sound formats, MIDI files don’t representsampled sound data. Rather, they represent virtual musicalinstruments that synthesize sound according to complexalgorithms that attempt to mirror the acoustic characteristics<strong>of</strong> real pianos, guitars, or other instruments. SinceMIDI is like a “score” for the virtual instruments ratherthan storing the sounds, it is much more compact thansampled sound formats. MIDI is generally used for musiccomposition rather than casual listening.MP3MP3 is actually a component <strong>of</strong> the MPEG (Moving PictureExpert Group) multimedia st<strong>and</strong>ard, <strong>and</strong> st<strong>and</strong>s for MPEG-1 Audio Layer 3. It is now the most popular sound format,using compression to provide a balance <strong>of</strong> sound quality

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!