34_split_Introduction to Algorithms 2nd Edition

34_split_Introduction to Algorithms 2nd Edition - 1.2...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1.2 Algorithms as a technology 11 Efficiency Algorithms devised to solve the same problem often differ dramatically in their efficiency. These differences can be much more significant than differences due to hardware and software. As an example, in Chapter 2, we will see two algorithms for sorting. The first, known as insertion sort , takes time roughly equal to c 1 n 2 to sort n items, where c 1 is a constant that does not depend on n . That is, it takes time roughly proportional to n 2 . The second, merge sort , takes time roughly equal to c 2 n lg n , where lg n stands for log 2 n and c 2 is another constant that also does not depend on n . Insertion sort usually has a smaller constant factor than merge sort, so that c 1 < c 2 . We shall see that the constant factors can be far less significant in the running time than the dependence on the input size n . Where merge sort has a factor of lg n in its running time, insertion sort has a factor of n , which is much larger. Although insertion sort, which is much larger....
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online