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.

446 sorting <strong>and</strong> searching• Discman CD-based music player (1984)• H<strong>and</strong>ycam camcorder <strong>and</strong> Video format (1985)• Digital audio tape, or DAT (1987)• Blu-ray optical discSony would also become a major player in the consolegaming market (see gaming console). In 1994 the companyintroduced the PlayStation, followed by later modelsin 2000 <strong>and</strong> 2006. Sony is also a significant seller <strong>of</strong> digitalcameras, including the Mavica floppy disc (later CD), sincediscontinued. The company also introduced its proprietary“memory stick” for storage.Stumbles <strong>and</strong> SuccessesIn 2005 a controversy erupted when it was revealed thatSony music CDs included as part <strong>of</strong> their copy protection(see also digital rights management) a “rootkit” that couldallow PCs to be compromised. Sony eventually agreed withthe Federal Trade Commission (FTC) to exchange theaffected CDs <strong>and</strong> to reimburse damage to consumers’ computersthat might have occurred while attempting to removethe s<strong>of</strong>tware. However, in 2007 a similar problem arose withthird-party s<strong>of</strong>tware packaged with Sony memory sticks.Around the same time, Sony had to recall laptop batteriesthat had serious flaws that could cause them to overheat<strong>and</strong> catch fire. In 2006 Sony <strong>and</strong> Dell agreed to replace over4.1 million laptop batteries—this was followed by 1.8 millionSony batteries in Apple laptops <strong>and</strong> 526,000 in IBM<strong>and</strong> Lenovo laptops.Despite these setbacks, Sony continues to be very successful,with $70.3 billion in revenue <strong>and</strong> a net income <strong>of</strong> $1.07billion in 2007, <strong>and</strong> about 163,000 employees worldwide.Further ReadingLuh, Shu Shin. Business the Sony Way: Secrets <strong>of</strong> the World’s MostInnovative Electronics Giant. New York: Wiley, 2003.Nathan, John. Sony. New York: Houghton Mifflin, 1999.Sony America. Available online. URL: http://www.sony.com/.Accessed November 18, 2007.Sony Playstation. Available online. URL: http://www.us.playstation.com/. Accessed November 18, 2007.sorting <strong>and</strong> searchingBecause they are so fundamental to maintaining databases,the operations <strong>of</strong> sorting (putting data records in order) <strong>and</strong>searching (finding a desired record) have received extensiveattention from computer scientists. A variety <strong>of</strong> different<strong>and</strong> quite interesting sorting methods have been devised(see algorithm).Any application that involves keeping track <strong>of</strong> a significantnumber <strong>of</strong> data records will have to keep them sortedin some way. After all, if records are simply inserted as theyarrive without any attempt at order, the time it will take t<strong>of</strong>ind a given record will, on the average, be the time it wouldtake to search through half the records in the database.While this might not matter for a few hundred records ona fast modern computer, it would be quite unacceptable fordatabases that might have millions <strong>of</strong> records.Sorting ConsiderationsWhile some sorting algorithms are better than others inalmost all cases, there are basic considerations for choosingan approach to sorting. The most obvious is how fastthe algorithm can sort the number <strong>of</strong> records the applicationis likely to encounter. However, it is also necessary toconsider whether the speed <strong>of</strong> the sort increases steadily(linearly) as the number <strong>of</strong> records increases, or it becomesproportionately worse. That is, if an algorithm can sort athous<strong>and</strong> records in two seconds, will it take 20 seconds for10,000 records, or perhaps five minutes?In most cases one assumes that the records to be sortedare in more or less r<strong>and</strong>om order, but what happens if therecords to be sorted are already partly sorted . . . or almostcompletely sorted? Some algorithms can take advantage <strong>of</strong>the partial sorting <strong>and</strong> complete the job far more quicklythan otherwise. Other algorithms may slow down drasticallyor even produce errors under those conditions.The range or variation in the key (the data field by whichrecords are being sorted) may also play a role. In some casesif the keys are close together, some algorithms may be ableto take advantage <strong>of</strong> that fact.Finally, the available computer resources must be considered.Today many desktop PCs have 1 GB (gigabyte) ormore <strong>of</strong> main memory (RAM), while servers or mainframesmay have several GBs. If the database is small enough that itcan be entirely kept in main memory, sorting is fast becauseany record can be accessed in the same amount <strong>of</strong> time atelectronic speeds. If, however, part <strong>of</strong> the database must bekept in secondary storage (such as hard drives), the sortingprogram will have to be designed so that it reads a number<strong>of</strong> records from the hard drive in a single reading operation,in order to avoid the overhead <strong>of</strong> repeated disk operations.Most likely the individual batches will be read fromthe disk, sorted in memory, written back to disk, <strong>and</strong> thenmerged to sort the whole database.Sorting AlgorithmsThere are numerous sorting algorithms ranging from theeasy-to-underst<strong>and</strong> to the commonly used to the exotic <strong>and</strong>quirky. Only the highlights can be covered here; see FurtherReading for sources for more detailed discussions.Selection SortThe simplest <strong>and</strong> least efficient kind <strong>of</strong> sort is called the selectionsort. Rather like a bridge player organizing a h<strong>and</strong>, theselection sort involves finding the record with the lowest key<strong>and</strong> swapping it with the first record, then scanning backthrough for the next lowest key <strong>and</strong> swapping it with the secondrecord, <strong>and</strong> so on until all the records are sorted. Whilethis uses memory very efficiently (since the records are sortedin place), it is not only slow, but also gets worse fast. That is,the time taken to sort n records is proportional to n 2 .The selection approach suffers because on each pass thesort determines not only the record with the lowest key but

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

Saved successfully!

Ooh no, something went wrong!