Skip to main content Accessibility help
×
Hostname: page-component-77c89778f8-vsgnj Total loading time: 0 Render date: 2024-07-21T08:26:55.195Z Has data issue: false hasContentIssue false

24 - Logarithms and Exponentials

Published online by Cambridge University Press:  05 June 2012

Jeff Edmonds
Affiliation:
York University, Toronto
Get access

Summary

Logarithms log2(n) and exponentials 2n arise often when analyzing algorithms.

Uses: These are some of the places that you will see them.

Divide a Logarithmic Number of Times: Many algorithms repeatedly cut the input instance in half. A classic example is binary search (Section 1.4): You take something of size n and you cut it in half, then you cut one of these halves in half, and one of these in half, and so on. Even for a very large initial object, it does not take very long until you get a piece of size below 1. The number of divisions required is about log2(n). Here the base 2 is because you are cutting them in half. If you were to cut them into thirds, then the number of times to cut would be about log3(n).

A Logarithmic Number of Digits: Logarithms are also useful because writing down a given integer value n requires 「log10(n + 1)」 decimal digits. For example, suppose that n = 1,000,000 = 106. You would have to divide this number by 10 six times to get to 1. Hence, by definition, log10(n) = 6. This, however, is the number of zeros, not the number of digits. We forgot the leading digit 1.

Type
Chapter
Information
Publisher: Cambridge University Press
Print publication year: 2008

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

Save book to Kindle

To save this book to your Kindle, first ensure coreplatform@cambridge.org is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.

Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

Find out more about the Kindle Personal Document Service.

  • Logarithms and Exponentials
  • Jeff Edmonds, York University, Toronto
  • Book: How to Think About Algorithms
  • Online publication: 05 June 2012
  • Chapter DOI: https://doi.org/10.1017/CBO9780511808241.026
Available formats
×

Save book to Dropbox

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.

  • Logarithms and Exponentials
  • Jeff Edmonds, York University, Toronto
  • Book: How to Think About Algorithms
  • Online publication: 05 June 2012
  • Chapter DOI: https://doi.org/10.1017/CBO9780511808241.026
Available formats
×

Save book to Google Drive

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.

  • Logarithms and Exponentials
  • Jeff Edmonds, York University, Toronto
  • Book: How to Think About Algorithms
  • Online publication: 05 June 2012
  • Chapter DOI: https://doi.org/10.1017/CBO9780511808241.026
Available formats
×