Help with Logarithms: Binary Searches & Phone Books

  • Thread starter lokisapocalypse
  • Start date
  • Tags
    Logarithms
In summary, a binary search of x items takes at most log base 2 (x) searches to find what you are looking for, assuming the data is sorted. If using a phone book as an example, with x names and y names on z pages, it takes log base 2 (y) searches to find the page and then log base 2 (z) searches to find the name on that page. This means that the number of searches is equal to log base 2 (x) = log base 2 (y) + log base 2 (z). This can be proven using the product rule for logarithms.
  • #1
lokisapocalypse
32
0
I am working on some homework about binary searches. In case you don't know, a binary search of x items takes at most log base 2 (x) searches to find what you are looking for (assuming it is sorted data of course). Now we are asked if using a phone book as an example, we have a reference to the first name on each page, how does that change the at most number of searches.

In other words, if I have x names in the phone book with y names on z pages (x = y*z). How much is that different than log base 2 (x). Using this method it takes at most log base 2 (y) searches to find the page and then log base 2 (z) searches to find the name on that page ( log base 2 (y) + log base 2 (z) ). It seems to be the case that log base 2 (x) = log base 2 (y) + log base 2 (z). Can anyone prove this for me? Thanks.
 
Physics news on Phys.org
  • #2
It's not clear what you want to prove. If you sinply want to prove that, given x = yz, then log(x) = log(y) + log(z) simply recall the product rule for logarithms : log(yz) = log(y) + log(z).
...but I suspect you are asking for something else.

I'm not sure, so I'll allow you to clarify.
 
Last edited:
  • #3
OR that 2^(x)*2^(y)=2^(x+y)
 
  • #4
Actually that was all I was asking for, thanks!
 

What are logarithms and why are they useful in binary searches?

Logarithms are mathematical functions that help us solve equations involving exponential growth and decay. In binary searches, they are useful because they help us divide a large search space into smaller, more manageable parts, making the search more efficient.

How do you use logarithms in binary searches?

In binary searches, we use logarithms to determine the number of times we need to divide the search space in half in order to find our target value. This is known as the "depth" of the search tree, and it can be calculated using the logarithm base 2 of the number of elements in the search space.

What is the relationship between logarithms and phone books?

In phone books, the names are listed in alphabetical order, making it easy to find a specific name by using a binary search. The number of times we need to divide the phone book in half to find a name is equivalent to the depth of the binary search tree, which can be calculated using logarithms.

How do you apply binary search and logarithms to phone books?

To apply binary search and logarithms to phone books, we first need to determine the number of names in the phone book and calculate the depth of the search tree using logarithms. Then, we can use the first letter of the name we are looking for to divide the phone book in half and continue this process until we find the specific name we are searching for.

Are there any limitations to using logarithms and binary searches in phone books?

Yes, there are some limitations to using logarithms and binary searches in phone books. These methods work best when the search space is already ordered, such as in a phone book, but may not be as efficient for unsorted or constantly changing data. Additionally, if the phone book is very small, the time saved by using a binary search may not be significant compared to a simple linear search.

Similar threads

Replies
4
Views
732
  • Precalculus Mathematics Homework Help
Replies
5
Views
1K
Replies
10
Views
1K
  • Introductory Physics Homework Help
Replies
3
Views
2K
  • Introductory Physics Homework Help
Replies
1
Views
789
  • Introductory Physics Homework Help
Replies
1
Views
541
  • Linear and Abstract Algebra
Replies
1
Views
615
  • General Math
Replies
2
Views
9K
  • Introductory Physics Homework Help
Replies
10
Views
502
  • Introductory Physics Homework Help
Replies
3
Views
164
Back
Top