Nepedia
Back to Discover
Independent Reader
💻

Time complexity

technology Maturity 11-13 Next article →

Computers follow a set of steps to finish a job. This set of steps is called an algorithm.

comparison computational complexity
comparison computational complexity

We want to know how much time an algorithm takes. We call this time complexity. It is hard to guess the exact time. Instead, we count the number of simple steps. We assume each step takes a fixed amount of time.

Sometimes, the same job takes different times. This happens if the input is different. To be safe, we often look at the worst-case. This is the most time a job could take. We also look at the average-case. This is the middle ground for all possible inputs.

We use a special way to write this. It is called big O notation. It shows how the time changes as the input gets bigger.

Some jobs are very fast. Constant time means the time stays the same. It does not matter if the input is big or small.

Other jobs change with the input. Linear time means the time grows at a steady rate. If the input doubles, the time also doubles.

comparison computational complexity
comparison computational complexity

There are many other ways to measure speed. Some jobs take logarithmic time. This is very efficient. The work grows slowly even as the input gets large.

208 words

Where will your curiosity go next?

Keep exploring at your chosen reading level.

🖼️ Images & Media (1)
File:comparison computational complexity.svg
comparison computational complexity.svg
More to explore

What is Nepedia?

A free, ad-free encyclopedia for children. Every article is written at five reading levels, so the same page works for a five-year-old and a fifteen-year-old — use the level switcher above to see this one change. No account needed to read.