DEV Community

Discussion on: AN OUTSTANDING EXPOSITION OF THE "Big O" NOTATION

Collapse
 
incrementis profile image
Akin C.

Hello Onyeanuna Prince,

Thank you for your article.
It's easy to read and understand.
I particularly like the diagram regarding Big O notations.
Also, I would have liked to see a simple example of the O(Log N) example, but I understand that the O(Log N) is a bit difficult to explain.

Collapse
 
aahil13 profile image
Onyeanuna prince

Thank you for reading, and your very honest and beautiful comments, it means alot.

Examples on O(Log N) are quite long and alittle bit complex, adding them here would have overstepped the goal of this article, which is making this subject as simple as possible.

You can also go through some resources on binary search algorithm.

Collapse
 
aminmansuri profile image
hidden_dude

The binary search algorithm is simple.

Basically:

  1. choose the middle item, if that's the one, you're done!
  2. if it's less than the middle item, throw away the top half and go to 1.
  3. if it's more than the middle item, throw away the bottom half and go to 1.

Do this until you run out of an array.

The concept of Log N (base 2, also written Lg N sometimes) is to discard half your problem with each iteration.

For such cases you're problem will grow only logarithmically.

Thread Thread
 
aahil13 profile image
Onyeanuna prince

This is perfectly explained!!!
This is amazing 🤩