So why is it that if u have (n) items, you have to divide it by 2, log(n) times till you get to 1 item?
This is often the analysis needed for sort algorithms e.g. Merge sort and quick sort.
The way to understand it is to think about how many times you have to divide the list in 2 until you you have only 1 item left.
Mathematically:
n / (2^x) = 1
n = 2^x
x = log(n)
Where:
n is the number of items originally on the list
x is the number of times it takes to divide the list in 2
Log is base 2
Thanks for this type of tech notes. You explains the log in so simple way and in short form also. These type of tutorials helps in our study also. Mostly I discussed your tutorials with my friends.
ReplyDeleteelectronic signature
Glad you found it useful :-)
ReplyDelete