The Self-Taught Computer Scientist


Chapter 1 What Is an Algorithm? 17


Download 1.48 Mb.
Pdf ko'rish
bet27/147
Sana17.06.2023
Hajmi1.48 Mb.
#1540634
1   ...   23   24   25   26   27   28   29   30   ...   147
Bog'liq
books-library.net-11301817Az7X6

Chapter 1 What Is an Algorithm?
17
for your algorithm. Maybe you have an O(
n**2) algorithm, but in its best- case scenario, it is O(n), 
and your data happens to fit its best- case scenario. In that case, the algorithm may be a good choice.
The decisions you make about algorithms can have enormous consequences in the real world. For 
example, say you are a web developer responsible for writing an algorithm that responds to a customer’s 
web request. Whether you decide to write a constant or quadratic algorithm could make the difference 
between your website loading in less than one second, making your customer happy, and taking more 
than a minute, which may cause you to lose customers before the request loads.
Vocabulary
algorithm: A sequence of steps that solves a problem.
run time: The amount of time it takes your computer to execute an algorithm written in a program-
ming language like Python.
size of the problem: The variable 
n in an equation that describes the number of steps in an algorithm.
big O notation: A mathematical notation that describes how an algorithm’s time or space require-
ments increase as the size of 
n increases.
order of magnitude: A class in a classification system where each class is many times greater or 
smaller than the one before.
time complexity: The maximum number of steps an algorithm takes to complete as 
n gets larger.
constant time: An algorithm runs in constant time when it requires the same number of steps 
regardless of the problem’s size.
logarithmic time: An algorithm runs in logarithmic time when its run time grows in proportion to 
the logarithm of the input size.
linear time: An algorithm runs in linear time when it grows at the same rate as the problem’s size.
log- linear time: An algorithm runs in log- linear time when it grows as a combination (multiplica-
tion) of logarithmic and linear time complexities.

Download 1.48 Mb.

Do'stlaringiz bilan baham:
1   ...   23   24   25   26   27   28   29   30   ...   147




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling