DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Data Engineering
  3. Data
  4. Calculating Big O

Calculating Big O

Big O seems to be everywhere. But what is Big O? What is the point of knowing Big O? Will Big O calculation improve my coding skills? Is it even worth trying?

Amuda Adeolu user avatar by
Amuda Adeolu
·
Apr. 25, 17 · Tutorial
Like (8)
Save
Tweet
Share
20.60K Views

Join the DZone community and get the full member experience.

Join For Free

Big O simple means Big Order. "Big" is something of considerable importance or seriousness, and "order" is the power with which your values changes.

Big O can also be considered a modern way of calculating the performance of different data sizes. With a good and solid foundation in Big O, your programming or software life becomes easy. Big O is used in DSAs (data structures and algorithms).

You need Big O to ensure that your software has very good performance with both small and big data. Imagine that you are writing a small search application to look for one million pieces of sorted data stored in one hundred machines that are connected to a single database — that means one thousand pieces of data on each machine. How can you find the data that you want?

Binary and linear will do that for you, but which one should you go for? That is where Big O calculation comes in. Remember your high school logarithms? Log 10 base 10 = 1 …since all the data are connected to 100 machines to a single database, linear search (looking for the data one by one until you see what you are looking for) could be a nice approach, but it would be time-consuming.

Here comes the Big O calculator! As a smart person, you should be thinking of going to the machine with the data that you are looking for, i.e using the binary search method and checking if the middle data match what you are looking for.

Log 10 of 1,000,000 = 6 into log 2 that will be 19.932 ~ 20 — meaning that you only have to look for any data you are looking for in 1,000,000 data in 20 times, maximum. The question is, how long will it take me to get what I'm looking for? You know that smartest way to get the data you looking for. It’s simple. Take the following: 

T = time and K = constant.

T = K (time is the constant of any specified algorithm).

T = K Log 10 (N) into Log 2 (N). So, if Log 10 (1,000,000) into Base 2 is 20, T = 20K and K = T/20.

Take K = Log 2 (N)/N.

K = 20/1,000,000; K = 20 (0.00002); K = 0.0004.

T = 0.0004 hour; T = 0.0004 * 60; T = 0.024 minute; T = 0.024 * 60; T = 1.44 seconds.

Isn’t that smart?

Now, you can choose the best solution.

There are many ways that Big O can be calculated. Some of them are:

  • Invariant: Conditions that remain unchanged as the algorithm proceeds.

  • N loop: Whenever you see nested loops such as those in this algorithm, you can suspect that an algorithm runs in O(N2) time. The outer loop executes N times and the inner loop executes N (or perhaps N divided by some constant) times for each cycle of the outer loop. This means you’re doing something approximately N*N or N2 times.

Lastly, memory space also matters a lot.

That's it. Thanks for reading!

Data (computing)

Published at DZone with permission of Amuda Adeolu. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • What Was the Question Again, ChatGPT?
  • 7 Awesome Libraries for Java Unit and Integration Testing
  • API Design Patterns Review
  • Microservices Discovery With Eureka

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: