- Big-O used to measure the speed of an algorithm
Efficiency of an Algorithm
- The algorithm is a set of processes for a task
- Efficiency tells how good or bad the algorithm is, can be measured in terms of time and space.
The less time (how fast) and less space (how much memory), the better the operation (algorithm)
Counting Primitive Operations
- Simplest analytical way to measure runtime is to count the number of primitive operations
- By assuming. that each primitive operation has constant execution time
The more operations, the more running time
7 Primitive Operations
- Assigning a value
x = 5 - Calling a method
Max(5,4) - Performing an arithmetic operations (+, -, , /, %)
x+5 - Comparing two numbers
x>y - Indexing into an array
A[1] - Following an object reference
c.radius - Returning from a method
return x;
Complexity Function
- Can be used to describe the number of basic operations of data structure of size
- It’s normally denoted as
- tells numbers of steps and also time
The more , the more running time. The less , the less running time.
Big-O Notation
- Big O notation is a mathematical notation that describes how an algorithm's time or space requirements grow as the size of its input increases. (Maybe to )
- That is is less than or equal to another function up to a constant factor and in the asymptotic sense as grows toward
- Big-O denotes as (inside is a function of with no coefficient)
- It approximates the performance for a very large
- Given the input size , an algorithm analysis focuses only on growth rate of time or space used
- Ex. , ,
- Big-O implies how much space (how much memory) and time (how fast) is needed approximately to run an algorithm
- The highest degree term controls the asymptotic growth rate of
- Big-O can be used to compare the algorithms’ performances
- เวลา Compare ก็ให้มองเป็นโจทย์แบบเปรียบเทียบ

Counting Terms in Arithmetic Sequences
- อันนี้เอาไว้ใช้หาจำนวน Term ง่าย ๆ แบบเป็นสูตรเฉย ๆ
- โดยหา คือจำนวน Term จากสมการนี้ – เดี๋ยวได้ใช้ ใน For Loop เพื่อนับจำนวนครั้ง
- อนุกรมเลขคณิต